4using System.Threading.Tasks;
28 private static readonly
string[] JsonLdContentTypes =
new string[]
38 private static readonly
string[] JsonLdFileExtensions =
new string[]
61 if (Array.IndexOf(JsonLdContentTypes, ContentType) >= 0)
83 public async Task<ContentResponse>
DecodeAsync(
string ContentType,
byte[] Data, Encoding Encoding,
84 KeyValuePair<string, string>[] Fields, Uri BaseUri,
ICodecProgress Progress)
132 public Task<ContentResponse>
EncodeAsync(
object Object, Encoding Encoding,
ICodecProgress Progress, params
string[] AcceptedContentTypes)
134 if (Encoding is
null)
135 Encoding = Encoding.UTF8;
144 return Task.FromResult(
new ContentResponse(
new ArgumentException(
"Unable to encode object.", nameof(Object))));
146 StringBuilder sb =
new StringBuilder();
159 Text = sb.ToString();
162 byte[] Bin = Encoding.GetBytes(Text);
163 string ContentType = JsonLdContentTypes[0] +
"; charset=" + Encoding.WebName;
176 if (
string.Compare(FileExtension, JsonLdFileExtensions[0],
true) == 0)
178 ContentType = JsonLdContentTypes[0];
196 if (Array.IndexOf(JsonLdContentTypes, ContentType) >= 0)
198 FileExtension = JsonLdFileExtensions[0];
203 FileExtension =
null;
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.
static readonly string[] JsonContentTypes
JSON content types.
Encoder and Decoder of semantic information in JSON-LD Documents.
bool Decodes(string ContentType, out Grade Grade)
If the decoder decodes content of a given Internet Content Type.
const string DefaultExtension
jsonld
string[] FileExtensions
Supported file extensions.
string[] ContentTypes
Supported Internet Content Types.
JsonLdCodec()
Encoder and Decoder of semantic information in JSON-LD Documents.
async Task< ContentResponse > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri, ICodecProgress Progress)
Decodes an object
bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of content of a given file extension.
const string DefaultContentType
application/ld+json
Task< ContentResponse > EncodeAsync(object Object, Encoding Encoding, ICodecProgress Progress, params string[] AcceptedContentTypes)
Encodes an object
bool Encodes(object Object, out Grade Grade, params string[] AcceptedContentTypes)
If the encoder encodes a specific object.
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of content of a given content type.
Contains semantic information stored in a JSON-LD document.
static Task< JsonLdDocument > CreateAsync(string Text)
Contains semantic information stored in a turtle document.
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...
Interface for semantic models.
Interface for semantic triples.
ISemanticElement Object
Object element
ISemanticElement Predicate
Predicate element
ISemanticElement Subject
Subject element
BlankNodeIdMode
How blank node IDs are generated