2using System.Collections.Generic;
4using System.Threading.Tasks;
57 else if (Object is
bool &&
77 public Task<KeyValuePair<byte[], string>>
EncodeAsync(
object Object, Encoding Encoding, params
string[] AcceptedContentTypes)
82 Encoding = Encoding.UTF8;
86 if (Result.BooleanResult.HasValue)
88 string[][] Records =
new string[1][];
99 int i, c = OM.ColumnNames.Length;
101 for (i = 0; i < c; i++)
102 OM.ColumnNames[i] =
"?" + OM.ColumnNames[i];
109 Text =
TSV.
Encode(M, ElementToString,
false);
110 else if (Object is
bool b)
112 string[][] Records =
new string[1][];
118 throw new ArgumentException(
"Unable to encode object.", nameof(Object));
120 byte[] Bin = Encoding.GetBytes(Text);
123 return Task.FromResult(
new KeyValuePair<
byte[],
string>(Bin, ContentType));
126 private static string ElementToString(
IElement E)
132 StringBuilder sb =
new StringBuilder();
135 sb.Append(ElementToString(Triple.Subject));
137 sb.Append(ElementToString(Triple.Predicate));
139 sb.Append(ElementToString(Triple.Object));
142 return sb.ToString();
145 return Obj.ToString();
170 FileExtension =
null;
Helps with parsing of commong data types.
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
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.
Helps with common JSON-related tasks.
static string Encode(string s)
Encodes a string for inclusion in JSON.
Implements a semantic triple.
Contains the results of a SPARQL query. https://www.w3.org/TR/2023/WD-sparql12-results-xml-20230516/ ...
Encoder and Decoder of semantic information from SPARQL queries using TSV. https://www....
bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of content of a given file extension.
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of content of a given content type.
string[] ContentTypes
Supported Internet Content Types.
SparqlResultSetTsvCodec()
Encoder and Decoder of semantic information from SPARQL queries using TSV.
string[] FileExtensions
Supported file extensions.
Task< KeyValuePair< byte[], string > > EncodeAsync(object Object, Encoding Encoding, params string[] AcceptedContentTypes)
Encodes an object
bool Encodes(object Object, out Grade Grade, params string[] AcceptedContentTypes)
If the encoder encodes a specific object.
Helps with common TSV-related tasks. (TSV=TAB Separated Values)
static string Encode(string[][] Records)
Encodes records as a Comma-separated values string.
static readonly string[] TsvContentTypes
TSV content types.
bool HasColumnNames
If the matrix has column names defined.
Basic interface for Internet Content encoders. A class implementing this interface and having a defau...
Interface for semantic nodes.
Basic interface for all types of elements.
object AssociatedObjectValue
Associated object value.
Basic interface for matrices.
delegate string ToString(IElement Element)
Delegate for callback methods that convert an element value to a string.