5using System.Threading.Tasks;
88 ContentType = ContentType.ToLower();
97 FileExtension =
string.Empty;
113 if (Object is IEnumerable<KeyValuePair<string, object>>)
120 Grade = Hint.CanEncodeJson;
123 else if (Object is
null ||
124 Object is IEnumerable ||
158 public Task<ContentResponse>
EncodeAsync(
object Object, Encoding Encoding,
164 AcceptedContentTypes))
169 if (Encoding is
null)
171 Encoding = Encoding.UTF8;
172 ContentType +=
"; charset=utf-8";
175 ContentType +=
"; charset=" + Encoding.WebName;
177 return Task.FromResult(
new ContentResponse(ContentType, Object, Encoding.GetBytes(Toon)));
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 TOON-related tasks.
static string Encode(object Object, bool Indent)
Encodes an object as TOON.
const string DefaultContentType
text/toon
static readonly string[] ToonFileExtensions
TOON file extensions.
string[] FileExtensions
Supported file extensions.
bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of an item, given its file extension.
ToonEncoder()
TOON encoder.
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of an item, given its Content-Type.
const string DefaultFileExtension
toon
bool Encodes(object Object, out Grade Grade, params string[] AcceptedContentTypes)
If the encoder encodes a given object.
string[] ContentTypes
Supported content types.
Task< ContentResponse > EncodeAsync(object Object, Encoding Encoding, ICodecProgress Progress, params string[] AcceptedContentTypes)
Encodes an object.
static readonly string[] ToonContentTypes
TOON content types.
Interface for reporting progress about an encoding or decoding.
Basic interface for Internet Content encoders. A class implementing this interface and having a defau...
Provides a JSON Encoding hint for an object that implements this interface.
Basic interface for vectors.