2using System.Collections.Generic;
4using System.Threading.Tasks;
83 public Task<object>
DecodeAsync(
string ContentType,
byte[] Data, Encoding Encoding, KeyValuePair<string, string>[] Fields, Uri BaseUri)
85 return Task.FromResult<
object>(Data);
96 if (
string.Compare(FileExtension,
"bin",
true) == 0)
103 ContentType =
string.Empty;
116 switch (ContentType.ToLower())
120 FileExtension =
"bin";
124 FileExtension =
string.Empty;
164 public Task<KeyValuePair<byte[], string>>
EncodeAsync(
object Object, Encoding Encoding, params
string[] AcceptedContentTypes)
166 if (Object is
byte[] Bin)
169 return Task.FromResult(
new KeyValuePair<
byte[],
string>(Obj.Data, Obj.ContentType));
171 throw new ArgumentException(
"Unable to encode as binary.", nameof(Object));
Task< KeyValuePair< byte[], string > > EncodeAsync(object Object, Encoding Encoding, params string[] AcceptedContentTypes)
Encodes 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.
Task< object > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri)
Decodes an object.
BinaryCodec()
Binary decoder.
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.
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.
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...