Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SymbolsDictionary.cs
Go to the documentation of this file.
2
3namespace System.Xml.Schema;
4
5internal sealed class SymbolsDictionary
6{
7 private int _last;
8
9 private readonly Hashtable _names;
10
12
13 private readonly ArrayList _particles;
14
15 private object _particleLast;
16
17 private bool _isUpaEnforced = true;
18
19 public int Count => _last + 1;
20
21 public bool IsUpaEnforced
22 {
23 get
24 {
25 return _isUpaEnforced;
26 }
27 set
28 {
30 }
31 }
32
33 public int this[XmlQualifiedName name]
34 {
35 get
36 {
37 object obj = _names[name];
38 if (obj != null)
39 {
40 return (int)obj;
41 }
42 if (_wildcards != null)
43 {
44 obj = _wildcards[name.Namespace];
45 if (obj != null)
46 {
47 return (int)obj;
48 }
49 }
50 return _last;
51 }
52 }
53
55 {
56 _names = new Hashtable();
57 _particles = new ArrayList();
58 }
59
60 public int AddName(XmlQualifiedName name, object particle)
61 {
62 object obj = _names[name];
63 if (obj != null)
64 {
65 int num = (int)obj;
66 if (_particles[num] != particle)
67 {
68 _isUpaEnforced = false;
69 }
70 return num;
71 }
72 _names.Add(name, _last);
73 _particles.Add(particle);
74 return _last++;
75 }
76
77 public void AddNamespaceList(NamespaceList list, object particle, bool allowLocal)
78 {
79 switch (list.Type)
80 {
81 case NamespaceList.ListType.Any:
82 _particleLast = particle;
83 break;
84 case NamespaceList.ListType.Other:
85 AddWildcard(list.Excluded, null);
86 if (!allowLocal)
87 {
88 AddWildcard(string.Empty, null);
89 }
90 break;
91 case NamespaceList.ListType.Set:
92 {
93 foreach (string item in list.Enumerate)
94 {
95 AddWildcard(item, particle);
96 }
97 break;
98 }
99 }
100 }
101
102 private void AddWildcard(string wildcard, object particle)
103 {
104 if (_wildcards == null)
105 {
106 _wildcards = new Hashtable();
107 }
108 object obj = _wildcards[wildcard];
109 if (obj == null)
110 {
112 _particles.Add(particle);
113 _last++;
114 }
115 else if (particle != null)
116 {
117 _particles[(int)obj] = particle;
118 }
119 }
120
122 {
124 foreach (XmlQualifiedName key in _names.Keys)
125 {
126 if (key != XmlQualifiedName.Empty && list.Allows(key))
127 {
128 arrayList.Add(_names[key]);
129 }
130 }
131 if (_wildcards != null)
132 {
133 foreach (string key2 in _wildcards.Keys)
134 {
135 if (list.Allows(key2))
136 {
138 }
139 }
140 }
141 if (list.Type == NamespaceList.ListType.Any || list.Type == NamespaceList.ListType.Other)
142 {
143 arrayList.Add(_last);
144 }
145 return arrayList;
146 }
147
148 public bool Exists(XmlQualifiedName name)
149 {
150 object obj = _names[name];
151 if (obj != null)
152 {
153 return true;
154 }
155 return false;
156 }
157
158 public object GetParticle(int symbol)
159 {
160 if (symbol != _last)
161 {
162 return _particles[symbol];
163 }
164 return _particleLast;
165 }
166
167 public string NameOf(int symbol)
168 {
169 foreach (DictionaryEntry name in _names)
170 {
171 if ((int)name.Value == symbol)
172 {
173 return ((XmlQualifiedName)name.Key).ToString();
174 }
175 }
176 if (_wildcards != null)
177 {
179 {
180 if ((int)wildcard.Value == symbol)
181 {
182 return (string)wildcard.Key + ":*";
183 }
184 }
185 }
186 return "##other:*";
187 }
188}
virtual int Add(object? value)
virtual ICollection Keys
Definition Hashtable.cs:532
virtual void Add(object key, object? value)
Definition Hashtable.cs:676
void AddWildcard(string wildcard, object particle)
ICollection GetNamespaceListSymbols(NamespaceList list)
bool Exists(XmlQualifiedName name)
int AddName(XmlQualifiedName name, object particle)
void AddNamespaceList(NamespaceList list, object particle, bool allowLocal)
static readonly XmlQualifiedName Empty