Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
NamedDictionary.cs
1using System.Collections.Generic;
3
4namespace Waher.Content
5{
12 public class NamedDictionary<TKey, TValue> : Dictionary<TKey, TValue>
13 {
18 : base()
19 {
20 }
21
27 public NamedDictionary(string LocalName, string Namespace)
28 : base()
29 {
30 this.LocalName = LocalName;
31 this.Namespace = Namespace;
32 }
33
38 public NamedDictionary(IDictionary<TKey, TValue> Dictionary)
39 : base(Dictionary)
40 {
41 }
42
47 public NamedDictionary(IEqualityComparer<TKey> Comparer)
48 : base(Comparer)
49 {
50 }
51
56 public NamedDictionary(int Capacity)
57 : base(Capacity)
58 {
59 }
60
66 public NamedDictionary(IDictionary<TKey, TValue> Dictionary, IEqualityComparer<TKey> Comparer)
67 : base(Dictionary, Comparer)
68 {
69 }
70
76 public NamedDictionary(int Capacity, IEqualityComparer<TKey> Comparer)
77 : base(Capacity, Comparer)
78 {
79 }
80
85 public static NamedDictionary<string, object> ToNamedDictionary(IEnumerable<KeyValuePair<string, IElement>> Dictionary)
86 {
88
89 foreach (KeyValuePair<string, IElement> P in Dictionary)
90 {
91 switch (P.Key)
92 {
93 case "__name":
94 case "__local":
95 Result.LocalName = P.Value.AssociatedObjectValue?.ToString() ?? string.Empty;
96 break;
97
98 case "__namespace":
99 case "__xmlns":
100 Result.Namespace = P.Value.AssociatedObjectValue?.ToString() ?? string.Empty;
101 break;
102
103 default:
104 Result[P.Key] = P.Value.AssociatedObjectValue;
105 break;
106 }
107 }
108
109 return Result;
110 }
111
115 public string LocalName { get; set; }
116
120 public string Namespace { get; set; }
121 }
122}
A Named dictionary is a dictionary, with a local name and a namespace. Use it to return content that ...
string LocalName
Local Name of dictionary.
static NamedDictionary< string, object > ToNamedDictionary(IEnumerable< KeyValuePair< string, IElement > > Dictionary)
Creates a Named Dictionary from a script object ex-nihilo
NamedDictionary(int Capacity, IEqualityComparer< TKey > Comparer)
A Named dictionary is a dictionary, with a local name and a namespace.
NamedDictionary(int Capacity)
A Named dictionary is a dictionary, with a local name and a namespace.
NamedDictionary(IDictionary< TKey, TValue > Dictionary, IEqualityComparer< TKey > Comparer)
A Named dictionary is a dictionary, with a local name and a namespace.
NamedDictionary()
A Named dictionary is a dictionary, with a local name and a namespace.
NamedDictionary(IDictionary< TKey, TValue > Dictionary)
A Named dictionary is a dictionary, with a local name and a namespace.
string Namespace
Namespace of dictionary.
NamedDictionary(IEqualityComparer< TKey > Comparer)
A Named dictionary is a dictionary, with a local name and a namespace.
NamedDictionary(string LocalName, string Namespace)
A Named dictionary is a dictionary, with a local name and a namespace.