Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
EmbeddedContent.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Threading.Tasks;
5
7{
12 {
16 Inline,
17
21 Attachment,
22
26 FormData,
27
31 Unknown
32 }
33
37 public class EmbeddedContent
38 {
39 private ContentDisposition disposition = ContentDisposition.Unknown;
40 private string contentType = null;
41 private string name = null;
42 private string fileName = null;
43 private string transferEncoding = null;
44 private string id = null;
45 private string description = null;
46 private byte[] raw = null;
47 private byte[] transferDecoded = null;
48 private object decoded = null;
49 private int? size = null;
50 private DateTimeOffset? creationDate = null;
51 private DateTimeOffset? modificationDate = null;
52
56 public string ContentType
57 {
58 get => this.contentType;
59 set => this.contentType = value;
60 }
61
66 {
67 get => this.disposition;
68 set => this.disposition = value;
69 }
70
74 public string Name
75 {
76 get => this.name;
77 set => this.name = value;
78 }
79
83 public string FileName
84 {
85 get => this.fileName;
86 set => this.fileName = value;
87 }
88
94 public string TransferEncoding
95 {
96 get => this.transferEncoding;
97 set => this.transferEncoding = value;
98 }
99
103 public byte[] Raw
104 {
105 get => this.raw;
106 set => this.raw = value;
107 }
108
113 public byte[] TransferDecoded
114 {
115 get => this.transferDecoded;
116 set => this.transferDecoded = value;
117 }
118
123 public object Decoded
124 {
125 get => this.decoded;
126 set => this.decoded = value;
127 }
128
132 public string ID
133 {
134 get => this.id;
135 set => this.id = value;
136 }
137
141 public string Description
142 {
143 get => this.description;
144 set => this.description = value;
145 }
146
150 public int? Size
151 {
152 get => this.size;
153 set => this.size = value;
154 }
155
159 public DateTimeOffset? CreationDate
160 {
161 get => this.creationDate;
162 set => this.creationDate = value;
163 }
164
168 public DateTimeOffset? ModificationDate
169 {
170 get => this.modificationDate;
171 set => this.modificationDate = value;
172 }
173
175 public override string ToString()
176 {
177 if (!string.IsNullOrEmpty(this.name))
178 return this.name;
179 else if (!string.IsNullOrEmpty(this.fileName))
180 return this.fileName;
181 else
182 return base.ToString();
183 }
184
185 internal async Task AssertEncoded()
186 {
187 if (!(this.raw is null))
188 return;
189
190 if (this.transferDecoded is null)
191 {
192 KeyValuePair<byte[], string> P = await InternetContent.EncodeAsync(this.decoded, Encoding.UTF8);
193 this.transferDecoded = P.Key;
194 this.contentType = P.Value;
195 this.raw = null;
196 }
197
198 if (this.raw is null)
199 {
200 this.raw = Encoding.ASCII.GetBytes(Convert.ToBase64String(this.transferDecoded));
201 this.transferEncoding = "base64";
202 }
203 }
204 }
205}
Static class managing encoding and decoding of internet content.
static Task< KeyValuePair< byte[], string > > EncodeAsync(object Object, Encoding Encoding, params string[] AcceptedContentTypes)
Encodes an object.
Represents content embedded in other content.
string FileName
Filename of embedded object.
ContentDisposition Disposition
Disposition of embedded object.
string Name
Name of embedded object.
string Description
Content-Description of embedded object, if defined.
DateTimeOffset? CreationDate
Creation-Date of content, if available.
string ContentType
Content-Type of embedded object.
object Decoded
Decoded body of embedded object. ContentType defines how TransferDecoded is transformed into Decoded.
int? Size
Size of content, if available.
byte[] TransferDecoded
Transformed body of embedded object. TransferEncoding defines how Raw is transformed into TransferDec...
byte[] Raw
Raw, untrasnformed body of embedded object.
string TransferEncoding
Content Transfer Encoding of embedded object, if defined. Affects how Raw is transformed into Transfe...
string ID
Content-ID of embedded object, if defined.
DateTimeOffset? ModificationDate
Modification-Date of content, if available.
ContentDisposition
Content disposition