5using System.Threading.Tasks;
37 public string[]
ToContentTypes =>
new string[] { CssCodec.DefaultContentType };
53 using (StreamReader rd =
new StreamReader(State.
From))
55 Cssx = await rd.ReadToEndAsync();
63 await State.
To.WriteAsync(Data, 0, Data.Length);
64 State.ToContentType +=
"; charset=utf-8";
90 return Convert(Cssx,
null, Session, FileName,
true);
105 return Convert(Cssx,
"¤",
"¤", State, Session, FileName, LockSession);
119 internal static async Task<string>
Convert(
string WebContent,
string StartDelimiter,
string StopDelimiter,
ConversionState State,
120 Variables Session,
string FileName,
bool PreserveVariables)
124 Exception ex =
new ArgumentNullException(
"No session defined.", nameof(Session));
135 if (PreserveVariables)
142 StringBuilder Result =
new StringBuilder();
145 int c = WebContent.Length;
152 j = WebContent.IndexOf(StartDelimiter, i);
157 Result.Append(WebContent[i..j]);
159 k = WebContent.IndexOf(StopDelimiter, j + 1);
163 Script = WebContent.Substring(j + 1, k - j - 1);
167 if (Value is SKColor Color)
169 else if (Value is
string s)
178 Result.Append(WebContent[i..]);
180 return Result.ToString();
184 if (PreserveVariables)
196 StringBuilder sb =
new StringBuilder();
198 return sb.ToString();
207 public static void ColorToCss(StringBuilder Result, SKColor Color)
209 if (Color.Alpha == 255)
212 Result.Append(Color.Red.ToString(
"X2"));
213 Result.Append(Color.Green.ToString(
"X2"));
214 Result.Append(Color.Blue.ToString(
"X2"));
218 Result.Append(
"rgba(");
219 Result.Append(Color.Red.ToString());
221 Result.Append(Color.Green.ToString());
223 Result.Append(Color.Blue.ToString());
Contains the state of a content conversion process.
Variables Session
Session states.
bool HasError
If an error should be returned.
Stream To
Stream pointing to where binary representation of content is to be sent.
string FromFileName
If the content is coming from a file, this parameter contains the name of that file....
Stream From
Stream pointing to binary representation of content.
Converts CSSX-files to CSS, by evaluating emebedded script and replacing it with results.
static Task< string > Convert(string Cssx, ConversionState State, string FileName)
Converts CSSX to CSS, using the current theme
async Task< bool > ConvertAsync(ConversionState State)
Performs the actual conversion.
string[] ToContentTypes
Converts content to these content types.
static Task< string > Convert(string Cssx, Variables Session, string FileName)
Converts CSSX to CSS, using the current theme
CssxToCss()
Converts CSSX-files to CSS, by evaluating emebedded script and replacing it with results.
string[] FromContentTypes
Converts content from these content types.
static void ColorToCss(StringBuilder Result, SKColor Color)
Converts a color to its CSS representation.
Grade ConversionGrade
How well the content is converted.
static string ColorToCss(SKColor Color)
Converts a color to its CSS representation.
static ThemeDefinition GetCurrentTheme(SessionVariables Variables)
Gets the current theme definition, based on the host information available in the session varaibles.
Contains properties for a theme.
void Prepare(Variables Variables)
Prepares a collection of variables for transforming content based on a theme.
Collection of session variables.
Static class managing binary representations of strings.
static Encoding Utf8WithBom
UTF-8 encoding with Byte Order Mark (BOM)
Class managing a script expression.
async Task< object > EvaluateAsync(Variables Variables)
Evaluates the expression, using the variables provided in the Variables collection....
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
static string ToExpressionString(object Value)
Converts an object to a string, that can be parsed as part of an expression.
virtual void Push()
Pushes the current set of variables to the stack. This state is restored by calling Pop....
virtual void Pop()
Pops a previously stored set of variables from the stack. Variables are stored on the stack by callin...
Basic interface for Internet Content encoders. A class implementing this interface and having a defau...