4using System.Threading.Tasks;
40 "gv",
"dot",
"neato",
"fdp",
"sfdp",
"twopi",
"circo"
83 public Task<ContentResponse>
DecodeAsync(
string ContentType,
byte[] Data, Encoding Encoding,
84 KeyValuePair<string, string>[] Fields, Uri BaseUri,
ICodecProgress Progress)
98 switch (FileExtension.ToLower())
111 ContentType =
string.Empty;
124 switch (ContentType.ToLower())
131 FileExtension =
string.Empty;
166 public Task<ContentResponse>
EncodeAsync(
object Object, Encoding Encoding,
ICodecProgress Progress, params
string[] AcceptedContentTypes)
169 return Task.FromResult(
new ContentResponse(
new ArgumentException(
"Unable to encode object, or content type not accepted.", nameof(Object))));
174 s = GraphVizDoc.GraphDescription;
176 s = Object.ToString();
178 if (Encoding is
null)
180 ContentType +=
"; charset=utf-8";
181 Encoding = Encoding.UTF8;
184 ContentType +=
"; charset=" + Encoding.WebName;
186 return Task.FromResult(
new ContentResponse(ContentType, Object, Encoding.GetBytes(s)));
Contains information about a response to a content request.
Static class managing encoding and decoding of internet content.
static bool IsAccepted(string ContentType, params string[] AcceptedContentTypes)
Checks if a given content type is acceptable.
GraphViz encoder/decoder.
string[] ContentTypes
Supported content types.
const string DefaultContentType
text/vnd.graphviz
bool Encodes(object Object, out Grade Grade, params string[] AcceptedContentTypes)
If the encoder encodes a given object.
static readonly string[] GraphVizContentTypes
GraphViz content types.
Task< ContentResponse > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri, ICodecProgress Progress)
Decodes an object.
GraphVizCodec()
GraphViz encoder/decoder.
Task< ContentResponse > EncodeAsync(object Object, Encoding Encoding, ICodecProgress Progress, params string[] AcceptedContentTypes)
Encodes an object.
bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of an item, given its file extension.
string[] FileExtensions
Supported file extensions.
static readonly string[] GraphVizFileExtensions
Plain text file extensions.
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of an item, given its Content-Type.
bool Decodes(string ContentType, out Grade Grade)
If the decoder decodes an object with a given content type.
Encapsulates a GraphViz document
Class managing GraphViz integration into Markdown documents.
Static class managing binary representations of strings.
static string GetString(byte[] Data, int Offset, int Count, Encoding DefaultEncoding)
Gets a string from its binary representation, taking any Byte Order Mark (BOM) into account.
Interface for reporting progress about an encoding or decoding.
Basic interface for Internet Content decoders. A class implementing this interface and having a defau...
Basic interface for Internet Content encoders. A class implementing this interface and having a defau...