4using System.Threading.Tasks;
34 "application/x-turtle"
42 private static readonly
string[] TurtleFileExtensions =
new string[]
87 public Task<ContentResponse>
DecodeAsync(
string ContentType,
byte[] Data, Encoding Encoding,
88 KeyValuePair<string, string>[] Fields, Uri BaseUri,
ICodecProgress Progress)
136 public Task<ContentResponse>
EncodeAsync(
object Object, Encoding Encoding,
ICodecProgress Progress, params
string[] AcceptedContentTypes)
138 if (Encoding is
null)
139 Encoding = Encoding.UTF8;
148 return Task.FromResult(
new ContentResponse(
new ArgumentException(
"Unable to encode object.", nameof(Object))));
150 StringBuilder sb =
new StringBuilder();
163 Text = sb.ToString();
166 byte[] Bin = Encoding.GetBytes(Text);
180 if (
string.Compare(FileExtension, TurtleFileExtensions[0],
true) == 0)
202 FileExtension = TurtleFileExtensions[0];
207 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.
Encoder and Decoder of semantic information in Turtle Documents.
const string DefaultContentType
text/turtle
Task< ContentResponse > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri, ICodecProgress Progress)
Decodes an object
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.
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of content of a given content type.
TurtleCodec()
Encoder and Decoder of semantic information in Turtle Documents.
string[] ContentTypes
Supported Internet Content Types.
static readonly string[] TurtleContentTypes
Internet Content-Types indicating a Turtle Document.
Task< ContentResponse > EncodeAsync(object Object, Encoding Encoding, ICodecProgress Progress, params string[] AcceptedContentTypes)
Encodes an object
const string DefaultExtension
ttl
bool Decodes(string ContentType, out Grade Grade)
If the decoder decodes content of a given Internet Content Type.
Contains semantic information stored in a turtle document. https://www.w3.org/TR/rdf12-turtle/ https:...
Plain text encoder/decoder.
const string DefaultContentType
text/plain
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