Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
CustomEncoder.cs
1using System;
2using System.Text;
3using System.Threading.Tasks;
5
7{
12 {
17 {
18 }
19
23 public string[] ContentTypes => Array.Empty<string>();
24
28 public string[] FileExtensions => Array.Empty<string>();
29
37 public bool Encodes(object Object, out Grade Grade, params string[] AcceptedContentTypes)
38 {
40 {
41 Grade = Grade.Perfect;
42 return true;
43 }
44 else
45 {
46 Grade = Grade.NotAtAll;
47 return false;
48 }
49 }
50
59 public Task<ContentResponse> EncodeAsync(object Object, Encoding Encoding,
60 ICodecProgress Progress, params string[] AcceptedContentTypes)
61 {
62 if (Object is CustomEncoding CustomEncoding)
64 else
65 return Task.FromResult(new ContentResponse(new ArgumentException("Unable to encode object.", nameof(Object))));
66 }
67
74 public bool TryGetContentType(string FileExtension, out string ContentType)
75 {
76 ContentType = string.Empty;
77 return false;
78 }
79
86 public bool TryGetFileExtension(string ContentType, out string FileExtension)
87 {
88 FileExtension = string.Empty;
89 return false;
90 }
91
92 }
93}
Encodes custom-encoded objects
CustomEncoder()
Encodes custom-encoded objects
string[] FileExtensions
Supported file extensions.
bool TryGetFileExtension(string ContentType, out string FileExtension)
Tries to get the file extension of an item, given its Content-Type.
Task< ContentResponse > EncodeAsync(object Object, Encoding Encoding, ICodecProgress Progress, params string[] AcceptedContentTypes)
Encodes an object.
string[] ContentTypes
Supported content types.
bool TryGetContentType(string FileExtension, out string ContentType)
Tries to get the content type of an item, given its file extension.
bool Encodes(object Object, out Grade Grade, params string[] AcceptedContentTypes)
If the encoder encodes a given object.
A custom encoded object.
string ContentType
Internet Content-Type of 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 encoders. A class implementing this interface and having a defau...
Grade
Grade enumeration
Definition: Grade.cs:7