Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
AsyncMarkdownHtmlContent.cs
1using System.Text;
2using System.Threading.Tasks;
8
10{
15 {
20 {
21 }
22
29 {
30 return OutputType == MarkdownOutputType.Html ? Grade.Ok : Grade.NotAtAll;
31 }
32
42 public async Task<string> GenerateStub(MarkdownOutputType Type, StringBuilder Output, string Title, MarkdownDocument Document)
43 {
44 string Id = Hashes.BinaryToString(Gateway.NextBytes(32));
45
46 if (string.IsNullOrEmpty(Title))
47 Title = await MarkdownToHtml.ToHtml(":hourglass_flowing_sand:", Document.Settings.Variables);
48 else
49 Title = XML.HtmlValueEncode(Title);
50
51 Output.Append("<div id=\"id");
52 Output.Append(Id);
53 Output.Append("\">");
54 Output.Append(Title);
55 Output.AppendLine("</div>");
56 Output.Append("<script type=\"text/javascript\">LoadContent(\"");
57 Output.Append(Id);
58 Output.AppendLine("\");</script>");
59
60 return Id;
61 }
62
69 public Task ReportResult(MarkdownOutputType Type, string Id, string Result)
70 {
71 return this.ReportResult(Type, Id, Result, false);
72 }
73
81 public Task ReportResult(MarkdownOutputType Type, string Id, string Result, bool More)
82 {
83 return ClientEvents.ReportAsynchronousResult(Id, "text/html; charset=utf-8", System.Text.Encoding.UTF8.GetBytes(Result), More);
84 }
85 }
86}
static Task< string > ToHtml(string Markdown)
Converts a Markdown snippet to a HTML snippet.
Contains a markdown document. This markdown document class supports original markdown,...
MarkdownSettings Settings
Markdown settings.
Variables Variables
Collection of variables. Providing such a collection enables script execution inside markdown documen...
Helps with common XML-related tasks.
Definition: XML.cs:19
static string HtmlValueEncode(string s)
Differs from Encode(String), in that it does not encode the aposotrophe or the quote.
Definition: XML.cs:209
The ClientEvents class allows applications to push information asynchronously to web clients connecte...
Definition: ClientEvents.cs:51
static Task ReportAsynchronousResult(string Id, string ContentType, byte[] Result)
Reports asynchronously evaluated result back to a client.
Pushes asynchronously generated HTML content to clients
async Task< string > GenerateStub(MarkdownOutputType Type, StringBuilder Output, string Title, MarkdownDocument Document)
Generates a stub in the output, that will be filled with the asynchronously generated content,...
Task ReportResult(MarkdownOutputType Type, string Id, string Result)
Method called when asynchronous result has been generated in a Markdown document.
Grade Supports(MarkdownOutputType OutputType)
How well specific content type is supported.
AsyncMarkdownHtmlContent()
Pushes asynchronously generated HTML content to clients
Task ReportResult(MarkdownOutputType Type, string Id, string Result, bool More)
Method called when asynchronous result has been generated in a Markdown document.
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:126
static byte[] NextBytes(int NrBytes)
Generates an array of random bytes.
Definition: Gateway.cs:3534
Contains methods for simple hash calculations.
Definition: Hashes.cs:59
static string BinaryToString(byte[] Data)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).
Definition: Hashes.cs:65
Interface for classes that help output asynchronous markdown output.
MarkdownOutputType
Markdown output type.
Grade
Grade enumeration
Definition: Grade.cs:7