2using System.Collections.Generic;
5using System.Threading.Tasks;
40 public async Task<KeyValuePair<byte[], string>>
EncodeAsync(
object Object, Encoding Encoding, params
string[] AcceptedContentTypes)
44 using (FileStream f = File.OpenRead(Ref.FileName))
46 if (f.Length >
int.MaxValue)
47 throw new OutOfMemoryException(
"File too large.");
49 byte[] Bin =
new byte[f.Length];
50 await f.ReadAsync(Bin, 0, (
int)f.Length);
52 return new KeyValuePair<byte[], string>(Bin, Ref.ContentType);
56 throw new ArgumentException(
"Unable to encode object.", nameof(Object));
101 FileExtension =
null;
string[] FileExtensions
Supported file extensions.
FileEncoder()
Encodes files.
bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of an item, given its file extension.
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of an item, given its Content-Type.
string[] ContentTypes
Supported content types.
async Task< KeyValuePair< byte[], string > > EncodeAsync(object Object, Encoding Encoding, params string[] AcceptedContentTypes)
Encodes an object.
bool Encodes(object Object, out Grade Grade, params string[] AcceptedContentTypes)
If the encoder encodes a given 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 encoders. A class implementing this interface and having a defau...