3using System.Threading.Tasks;
65 public async Task<ContentResponse>
EncodeAsync(
object Object, Encoding Encoding,
ICodecProgress Progress, params
string[] AcceptedContentTypes)
68 return new ContentResponse(
new ArgumentException(
"Unable to encode object.", nameof(Object)));
70 if ((Result.Variables?.Length ?? 0) != 3)
71 return new ContentResponse(
new ArgumentException(
"Graphs can only be generated for semantic-triple result sets.", nameof(Object)));
74 string SubjectVariable = Result.Variables[0];
75 string PredicateVariable = Result.Variables[1];
76 string ObjectVariable = Result.Variables[2];
84 if (Subject is
null || Predicate is
null || Object2 is
null)
85 return new ContentResponse(
new ArgumentException(
"Graphs can only be generated for semantic-triple result sets.", nameof(Object)));
87 Cube.Add(Subject, Predicate, Object2);
106 if (Encoding is
null)
108 ContentType = GraphVizCodec.DefaultContentType +
"; charset=utf-8";
109 Encoding = Encoding.UTF8;
112 ContentType = GraphVizCodec.DefaultContentType +
"; charset=" + Encoding.WebName;
114 Bin = Encoding.GetBytes(Graph);
117 return new ContentResponse(
new ArgumentException(
"Requestd Content-Type not acceptable.", nameof(AcceptedContentTypes)));
142 FileExtension =
null;
Contains information about a response to a content request.
const string ContentTypePng
image/png
const string ContentTypeSvg
image/svg+xml
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.
const string DefaultContentType
text/vnd.graphviz
GraphViz conversion utilities.
static Task< byte[]> DotToImage(string GraphText, ResultType ResultType)
Converts a GraphViz dot graph description to an image.
static string GenerateGraph(ISemanticModel Graph, string Title)
Generates a GraphViz dot graph from a semantic graph.
Encoder of semantic information from SPARQL queries as images.
string[] ContentTypes
Supported Internet Content Types.
bool Encodes(object Object, out Grade Grade, params string[] AcceptedContentTypes)
If the encoder encodes a specific object.
async 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 content of a given file extension.
SparqlResultSetImageEncoder()
Encoder and Decoder of semantic information from SPARQL queries using HTML.
string[] FileExtensions
Supported file extensions.
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of content of a given content type.
Contains the results of a SPARQL query. https://www.w3.org/TR/2023/WD-sparql12-results-xml-20230516/ ...
Interface for reporting progress about an encoding or decoding.
Basic interface for Internet Content encoders. A class implementing this interface and having a defau...
Interface for semantic nodes.
Interface for result records of a SPARQL query.
ResultType
Image types supported by GraphViz