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][];
98 else if (Object is
bool b)
100 string[][] Records =
new string[1][];
106 throw new ArgumentException(
"Unable to encode object.", nameof(Object));
108 byte[] Bin = Encoding.GetBytes(Text);
111 return Task.FromResult(
new KeyValuePair<
byte[],
string>(Bin, ContentType));
114 private static string ElementToString(
IElement E)
121 return Literal.StringValue;
124 StringBuilder sb =
new StringBuilder();
127 sb.Append(ElementToString(Triple.Subject));
129 sb.Append(ElementToString(Triple.Predicate));
131 sb.Append(ElementToString(Triple.Object));
134 return sb.ToString();
137 return Obj?.ToString() ??
string.Empty;
160 FileExtension =
null;
Helps with common CSV-related tasks. (CSV=Comma Separated Values)
static string Encode(string[][] Records)
Encodes records as a Comma-separated values string.
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.
Abstract base class for semantic literal values.
Implements a semantic triple.
Encoder and Decoder of semantic information from SPARQL queries using CSV. https://www....
string[] ContentTypes
Supported Internet Content Types.
string[] FileExtensions
Supported file extensions.
bool Encodes(object Object, out Grade Grade, params string[] AcceptedContentTypes)
If the encoder encodes a specific object.
bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of content of a given file extension.
Task< KeyValuePair< byte[], string > > EncodeAsync(object Object, Encoding Encoding, params string[] AcceptedContentTypes)
Encodes an object
SparqlResultSetCsvCodec()
Encoder and Decoder of semantic information from SPARQL queries using CSV.
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/ ...
static readonly string[] CsvContentTypes
CSV 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...
Basic interface for all types of elements.
object AssociatedObjectValue
Associated object value.