Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AccessorMapping.cs
Go to the documentation of this file.
2
4
5internal abstract class AccessorMapping : Mapping
6{
7 internal sealed class AccessorComparer : IComparer<ElementAccessor>
8 {
10 {
11 if (a1 == a2)
12 {
13 return 0;
14 }
15 int weight = a1.Mapping.TypeDesc.Weight;
16 int weight2 = a2.Mapping.TypeDesc.Weight;
17 if (weight == weight2)
18 {
19 return 0;
20 }
21 if (weight < weight2)
22 {
23 return 1;
24 }
25 return -1;
26 }
27 }
28
30
32
34
36
38
40
42
43 private bool _ignore;
44
45 internal bool IsAttribute => _attribute != null;
46
47 internal bool IsText
48 {
49 get
50 {
51 if (_text != null)
52 {
53 if (_elements != null)
54 {
55 return _elements.Length == 0;
56 }
57 return true;
58 }
59 return false;
60 }
61 }
62
63 internal bool IsParticle
64 {
65 get
66 {
67 if (_elements != null)
68 {
69 return _elements.Length != 0;
70 }
71 return false;
72 }
73 }
74
76 {
77 get
78 {
79 return _typeDesc;
80 }
81 set
82 {
84 }
85 }
86
88 {
89 get
90 {
91 return _attribute;
92 }
93 set
94 {
96 }
97 }
98
99 internal ElementAccessor[] Elements
100 {
101 get
102 {
103 return _elements;
104 }
105 set
106 {
108 _sortedElements = null;
109 }
110 }
111
113 {
114 get
115 {
116 if (_sortedElements != null)
117 {
118 return _sortedElements;
119 }
120 if (_elements == null)
121 {
122 return null;
123 }
127 return _sortedElements;
128 }
129 }
130
131 internal TextAccessor Text
132 {
133 get
134 {
135 return _text;
136 }
137 set
138 {
139 _text = value;
140 }
141 }
142
144 {
145 get
146 {
147 return _choiceIdentifier;
148 }
149 set
150 {
152 }
153 }
154
156 {
157 get
158 {
159 return _xmlns;
160 }
161 set
162 {
163 _xmlns = value;
164 }
165 }
166
167 internal bool Ignore
168 {
169 get
170 {
171 return _ignore;
172 }
173 set
174 {
175 _ignore = value;
176 }
177 }
178
180 {
181 get
182 {
183 if (_xmlns != null)
184 {
185 return _xmlns;
186 }
187 if (_attribute != null)
188 {
189 return _attribute;
190 }
191 if (_elements != null && _elements.Length != 0)
192 {
193 return _elements[0];
194 }
195 return _text;
196 }
197 }
198
200 {
201 }
202
204 : base(mapping)
205 {
206 _typeDesc = mapping._typeDesc;
207 _attribute = mapping._attribute;
208 _elements = mapping._elements;
209 _sortedElements = mapping._sortedElements;
210 _text = mapping._text;
211 _choiceIdentifier = mapping._choiceIdentifier;
212 _xmlns = mapping._xmlns;
213 _ignore = mapping._ignore;
214 }
215
216 internal static void SortMostToLeastDerived(ElementAccessor[] elements)
217 {
218 Array.Sort(elements, new AccessorComparer());
219 }
220
222 {
223 if (a == null)
224 {
225 if (b == null)
226 {
227 return true;
228 }
229 return false;
230 }
231 if (b == null)
232 {
233 return false;
234 }
235 if (a.Length != b.Length)
236 {
237 return false;
238 }
239 for (int i = 0; i < a.Length; i++)
240 {
241 if (a[i].Name != b[i].Name || a[i].Namespace != b[i].Namespace || a[i].Form != b[i].Form || a[i].IsNullable != b[i].IsNullable)
242 {
243 return false;
244 }
245 }
246 return true;
247 }
248
250 {
251 if (Elements != null && Elements.Length != 0)
252 {
253 if (!ElementsMatch(Elements, mapping.Elements))
254 {
255 return false;
256 }
257 if (Text == null)
258 {
259 return mapping.Text == null;
260 }
261 }
262 if (Attribute != null)
263 {
264 if (mapping.Attribute == null)
265 {
266 return false;
267 }
268 if (Attribute.Name == mapping.Attribute.Name && Attribute.Namespace == mapping.Attribute.Namespace)
269 {
270 return Attribute.Form == mapping.Attribute.Form;
271 }
272 return false;
273 }
274 if (Text != null)
275 {
276 return mapping.Text != null;
277 }
278 return mapping.Accessor == null;
279 }
280}
static void Sort(Array array)
Definition Array.cs:2329
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
int Compare(ElementAccessor a1, ElementAccessor a2)
bool Match(AccessorMapping mapping)
static void SortMostToLeastDerived(ElementAccessor[] elements)
ChoiceIdentifierAccessor _choiceIdentifier
static bool ElementsMatch(ElementAccessor[] a, ElementAccessor[] b)