4using System.Threading.Tasks;
26 public static readonly
string[]
TsvContentTypes =
new string[] {
"text/tab-separated-values" };
51 if (ContentType ==
"text/tab-separated-values")
73 public Task<ContentResponse>
DecodeAsync(
string ContentType,
byte[] Data, Encoding Encoding,
74 KeyValuePair<string, string>[] Fields, Uri BaseUri,
ICodecProgress Progress)
89 if (
string.Compare(FileExtension,
"tsv",
true) == 0)
91 ContentType =
"text/tab-separated-values";
109 switch (ContentType.ToLower())
111 case "text/tab-separated-values":
112 FileExtension =
"tsv";
116 FileExtension =
string.Empty;
131 (Object is
string[][] || Object is
IMatrix))
151 public Task<ContentResponse>
EncodeAsync(
object Object, Encoding Encoding,
156 if (Object is
string[][] Records)
161 return Task.FromResult(
new ContentResponse(
new ArgumentException(
"Unable to encode as TSV.", nameof(Object))));
163 if (Encoding is
null)
164 Encoding = Encoding.UTF8;
166 return Task.FromResult(
new ContentResponse(
"text/tab-separated-values", Object, Encoding.GetBytes(Tsv)));
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.
Helps with common TSV-related tasks. (TSV=TAB Separated Values)
static string Encode(string[][] Records)
Encodes records as a Comma-separated values string.
static string[][] Parse(string Tsv)
Parses a TSV string.
string[] ContentTypes
Supported content types.
Task< ContentResponse > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri, ICodecProgress Progress)
Decodes an object.
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of an item, given its Content-Type.
bool Encodes(object Object, out Grade Grade, params string[] AcceptedContentTypes)
If the encoder encodes a given object.
bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of an item, given its file extension.
static readonly string[] TsvFileExtensions
TSV content types.
string[] FileExtensions
Supported file extensions.
bool Decodes(string ContentType, out Grade Grade)
If the decoder decodes an object with a given content type.
Task< ContentResponse > EncodeAsync(object Object, Encoding Encoding, ICodecProgress Progress, params string[] AcceptedContentTypes)
Encodes an object.
static readonly string[] TsvContentTypes
TSV content types.
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...
Basic interface for matrices.