4using System.Threading.Tasks;
85 public Task<ContentResponse>
DecodeAsync(
string ContentType,
byte[] Data, Encoding Encoding,
86 KeyValuePair<string, string>[] Fields, Uri BaseUri,
ICodecProgress Progress)
99 if (
string.Compare(FileExtension,
"bin",
true) == 0)
106 ContentType =
string.Empty;
119 switch (ContentType.ToLower())
123 FileExtension =
"bin";
127 FileExtension =
string.Empty;
167 public Task<ContentResponse>
EncodeAsync(
object Object, Encoding Encoding,
170 if (Object is
byte[] Bin)
173 return Task.FromResult(
new ContentResponse(Obj.ContentType, Obj.Data, Obj.Data));
175 return Task.FromResult(
new ContentResponse(
new ArgumentException(
"Unable to encode as binary.", nameof(Object))));
Task< ContentResponse > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri, ICodecProgress Progress)
Decodes an object.
static readonly string[] BinaryFileExtensions
Binary content types.
const string DefaultContentType
text/plain
bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of an item, given its file extension.
BinaryCodec()
Binary decoder.
Task< ContentResponse > EncodeAsync(object Object, Encoding Encoding, ICodecProgress Progress, params string[] AcceptedContentTypes)
Encodes an object.
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of an item, given its Content-Type.
string[] FileExtensions
Supported file extensions.
bool Decodes(string ContentType, out Grade Grade)
If the decoder decodes an object with a given content type.
static readonly string[] BinaryContentTypes
Binary content types.
string[] ContentTypes
Supported content types.
bool Encodes(object Object, out Grade Grade, params string[] AcceptedContentTypes)
If the encoder encodes a given object.
Represents an encoded object.
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.
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...