Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ConversionState.cs
1using System;
2using System.IO;
3using Waher.Events;
4using Waher.Script;
5
6namespace Waher.Content
7{
15 public delegate bool TryGetLocalResourceFileName(string Resource, string Host, out string FileName);
16
20 public class ConversionState
21 {
22 private readonly TryGetLocalResourceFileName tryGetLocalResourceFileName;
23
42 public ConversionState(string FromContentType, Stream From, string FromFileName, string LocalResourceName, string URL,
45 {
46 this.FromContentType = FromContentType;
47 this.From = From;
48 this.FromFileName = FromFileName;
49 this.LocalResourceName = LocalResourceName;
50 this.URL = URL;
51 this.ToContentType = ToContentType;
52 this.To = To;
53 this.Session = Session;
54 this.Progress = Progress;
55 this.PossibleContentTypes = PossibleContentTypes;
56 this.ResourceMap = ResourceMap;
57 this.tryGetLocalResourceFileName = TryGetLocalResourceFileName;
58 }
59
63 public string FromContentType { get; }
64
68 public Stream From { get; }
69
74 public string FromFileName { get; set; }
75
79 public string LocalResourceName { get; set; }
80
84 public string URL { get; }
85
90 public string ToContentType { get; set; }
91
95 public Stream To { get; }
96
100 public Variables Session { get; }
101
105 public ICodecProgress Progress { get; }
106
110 public IResourceMap ResourceMap { get; }
111
116 public string[] PossibleContentTypes { get; }
117
121 public Exception Error { get; set; }
122
126 public bool HasError => !(this.Error is null);
127
135 public bool TryGetLocalResourceFileName(string Resource, string Host, out string FileName)
136 {
137 if (!(this.tryGetLocalResourceFileName is null))
138 {
139 try
140 {
141 return this.tryGetLocalResourceFileName(Resource, Host, out FileName);
142 }
143 catch (Exception ex)
144 {
145 Log.Exception(ex);
146 }
147 }
148
149 FileName = null;
150 return false;
151 }
152 }
153}
Contains the state of a content conversion process.
Variables Session
Session states.
string ToContentType
Content type of the content to convert to. This value might be changed, in case the converter finds a...
string[] PossibleContentTypes
Possible content types the converter is allowed to convert to. Can be null if there are no alternativ...
Exception Error
Error response, in case conversion should return an error.
bool HasError
If an error should be returned.
string LocalResourceName
Local resource name of file, if accessed from a web server.
string FromContentType
Content type of the content to convert from.
Stream To
Stream pointing to where binary representation of content is to be sent.
ConversionState(string FromContentType, Stream From, string FromFileName, string LocalResourceName, string URL, string ToContentType, Stream To, Variables Session, ICodecProgress Progress, IResourceMap ResourceMap, TryGetLocalResourceFileName TryGetLocalResourceFileName, params string[] PossibleContentTypes)
Contains the state of a content conversion process.
IResourceMap ResourceMap
Optional resource map.
string FromFileName
If the content is coming from a file, this parameter contains the name of that file....
ICodecProgress Progress
Optional interface for reporting progress during conversion.
bool TryGetLocalResourceFileName(string Resource, string Host, out string FileName)
Tries to get a file name for a resource, if local.
string URL
URL of resource, if accessed from a web server.
Stream From
Stream pointing to binary representation of content.
Static class managing the application event log. Applications and services log events on this static ...
Definition: Log.cs:14
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Definition: Log.cs:1657
Collection of variables.
Definition: Variables.cs:25
Interface for reporting progress about an encoding or decoding.
Basic interface for Resource maps.
Definition: IResourceMap.cs:7
delegate bool TryGetLocalResourceFileName(string Resource, string Host, out string FileName)
Delegate to callback functions that resolve local file names for local resources.