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.Collections.Generic;
3using System.Text;
4using System.Threading.Tasks;
6
8{
13 {
18 {
19 }
20
24 public string[] ContentTypes => Array.Empty<string>();
25
29 public string[] FileExtensions => Array.Empty<string>();
30
38 public bool Encodes(object Object, out Grade Grade, params string[] AcceptedContentTypes)
39 {
41 {
42 Grade = Grade.Perfect;
43 return true;
44 }
45 else
46 {
47 Grade = Grade.NotAtAll;
48 return false;
49 }
50 }
51
60 public Task<KeyValuePair<byte[], string>> EncodeAsync(object Object, Encoding Encoding, params string[] AcceptedContentTypes)
61 {
62 if (!(Object is CustomEncoding CustomEncoding))
63 throw new ArgumentException("Unable to encode object.", nameof(Object));
64
65 return Task.FromResult(new KeyValuePair<byte[], string>(CustomEncoding.Encoded, CustomEncoding.ContentType));
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
Task< KeyValuePair< byte[], string > > EncodeAsync(object Object, Encoding Encoding, params string[] AcceptedContentTypes)
Encodes an object.
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.
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.
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...
Grade
Grade enumeration
Definition: Grade.cs:7