Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ValidationSchema.cs
1using System;
2using System.IO;
3using System.Text;
4using System.Xml;
5using System.Xml.Schema;
10
12{
13 [CollectionName("ValidationSchemas")]
14 [TypeName(TypeNameSerialization.None)]
15 [ArchivingTime]
16 [Index("Namespace", "HashBase64")]
17 [Index("Namespace", "Created")]
18 public class ValidationSchema
19 {
20 private string objectId = null;
22 private string hashBase64 = string.Empty;
23 private string contentType = string.Empty;
24 private byte[] xmlSchema = null;
25 private HashFunction function = HashFunction.SHA256;
26 private DateTime created = DateTime.MinValue;
27 private XmlSchema parsed = null;
28
32 [ObjectId]
33 public string ObjectId
34 {
35 get => this.objectId;
36 set => this.objectId = value;
37 }
38
43 {
44 get => this.ns;
45 set => this.ns = value;
46 }
47
51 public string HashBase64
52 {
53 get => this.hashBase64;
54 set => this.hashBase64 = value;
55 }
56
60 [DefaultValue(HashFunction.SHA256)]
62 {
63 get => this.function;
64 set => this.function = value;
65 }
66
70 [DefaultValueNull]
71 public byte[] XmlSchema
72 {
73 get => this.xmlSchema;
74 set => this.xmlSchema = value;
75 }
76
80 [DefaultValueStringEmpty]
81 public string ContentType
82 {
83 get => this.contentType;
84 set => this.contentType = value;
85 }
86
90 public DateTime Created
91 {
92 get => this.created;
93 set => this.created = value;
94 }
95
99 public string Xml
100 {
101 get
102 {
103 Encoding Encoding;
104
105 if (string.IsNullOrEmpty(this.contentType))
106 Encoding = null;
107 else
108 {
109 HttpFieldContentType Header = new HttpFieldContentType("Content-Type", this.contentType);
110 Encoding = Header.Encoding;
111 }
112
113 return (Encoding ?? Encoding.UTF8).GetString(this.xmlSchema);
114 }
115 }
116
121 {
122 get
123 {
124 if (this.parsed is null)
125 {
126 using XmlReader r = XmlReader.Create(new MemoryStream(this.xmlSchema));
127 this.parsed = System.Xml.Schema.XmlSchema.Read(r, null);
128 }
129
130 return this.parsed;
131 }
132 }
133
134 }
135}
Content-Type HTTP Field header. (RFC 2616, §14.17)
Represents a case-insensitive string.
static readonly CaseInsensitiveString Empty
Empty case-insensitive string
TypeNameSerialization
How the type name should be serialized.
HashFunction
Hash method enumeration.
Definition: Hashes.cs:26