Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
StructMapping.cs
Go to the documentation of this file.
2
4
5internal sealed class StructMapping : TypeMapping, INameScope
6{
8
10
12
14
16
17 private bool _hasSimpleContent;
18
19 private bool _openModel;
20
21 private bool _isSequence;
22
24
26
28
30 {
31 get
32 {
33 return _baseMapping;
34 }
36 set
37 {
39 if (!base.IsAnonymousType && _baseMapping != null)
40 {
43 }
44 if (!value._isSequence || _isSequence)
45 {
46 return;
47 }
48 _isSequence = true;
50 {
52 {
53 structMapping.SetSequence();
54 }
55 }
56 }
57 }
58
60
61 internal bool IsFullyInitialized
62 {
63 get
64 {
65 if (_baseMapping != null)
66 {
67 return Members != null;
68 }
69 return false;
70 }
71 }
72
74 {
75 get
76 {
77 if (_elements == null)
78 {
79 _elements = new NameTable();
80 }
81 return _elements;
82 }
83 }
84
86 {
87 get
88 {
89 if (_attributes == null)
90 {
91 _attributes = new NameTable();
92 }
93 return _attributes;
94 }
95 }
96
97 object INameScope.this[string name, string ns]
98 {
99 get
100 {
101 object obj = LocalElements[name, ns];
102 if (obj != null)
103 {
104 return obj;
105 }
106 if (_baseMapping != null)
107 {
108 return ((INameScope)_baseMapping)[name, ns];
109 }
110 return null;
111 }
112 set
113 {
114 LocalElements[name, ns] = value;
115 }
116 }
117
119
121
122 internal bool HasXmlnsMember
123 {
124 get
125 {
127 {
128 if (structMapping.XmlnsMember != null)
129 {
130 return true;
131 }
132 }
133 return false;
134 }
135 }
136
138 {
139 get
140 {
141 return _members;
142 }
143 set
144 {
145 _members = value;
146 }
147 }
148
150 {
151 get
152 {
153 return _xmlnsMember;
154 }
155 set
156 {
158 }
159 }
160
161 internal bool IsOpenModel
162 {
163 get
164 {
165 return _openModel;
166 }
167 set
168 {
170 }
171 }
172
174 {
175 get
176 {
177 if (_scope == null)
178 {
179 _scope = new CodeIdentifiers();
180 }
181 return _scope;
182 }
183 set
184 {
185 _scope = value;
186 }
187 }
188
189 internal bool IsSequence
190 {
191 get
192 {
193 if (_isSequence)
194 {
195 return !base.TypeDesc.IsRoot;
196 }
197 return false;
198 }
199 set
200 {
202 }
203 }
204
206 {
207 declaringMapping = null;
208 if (BaseMapping != null)
209 {
211 if (memberMapping != null)
212 {
213 return memberMapping;
214 }
215 }
216 if (_members == null)
217 {
218 return null;
219 }
220 for (int i = 0; i < _members.Length; i++)
221 {
222 if (_members[i].Name == member.Name)
223 {
224 if (_members[i].TypeDesc != member.TypeDesc)
225 {
227 }
228 if (!_members[i].Match(member))
229 {
231 }
232 declaringMapping = this;
233 return _members[i];
234 }
235 }
236 return null;
237 }
238
239 internal bool Declares(MemberMapping member, string parent)
240 {
242 return FindDeclaringMapping(member, out declaringMapping, parent) != null;
243 }
244
246 {
247 if (BaseMapping == null || BaseMapping.TypeDesc.IsRoot)
248 {
249 _hasSimpleContent = !hasElements && text != null && !text.Mapping.IsList;
250 }
252 {
253 if (text != null || hasElements)
254 {
256 }
257 _hasSimpleContent = true;
258 }
259 else
260 {
261 _hasSimpleContent = false;
262 }
263 if (!_hasSimpleContent && text != null && !text.Mapping.TypeDesc.CanBeTextValue && (BaseMapping == null || BaseMapping.TypeDesc.IsRoot || (!text.Mapping.TypeDesc.IsEnum && !text.Mapping.TypeDesc.IsPrimitive)))
264 {
265 throw new InvalidOperationException(System.SR.Format(System.SR.XmlIllegalTypedTextAttribute, base.TypeDesc.FullName, text.Name, text.Mapping.TypeDesc.FullName));
266 }
267 }
268
269 internal bool HasExplicitSequence()
270 {
271 if (_members != null)
272 {
273 for (int i = 0; i < _members.Length; i++)
274 {
275 if (_members[i].IsParticle && _members[i].IsSequence)
276 {
277 return true;
278 }
279 }
280 }
281 if (_baseMapping != null)
282 {
284 }
285 return false;
286 }
287
288 internal void SetSequence()
289 {
290 if (!base.TypeDesc.IsRoot)
291 {
293 while (structMapping.BaseMapping != null && !structMapping.BaseMapping.IsSequence && !structMapping.BaseMapping.TypeDesc.IsRoot)
294 {
296 }
299 {
301 }
302 }
303 }
304}
static string XmlIllegalSimpleContentExtension
Definition SR.cs:1678
static string XmlInvalidXmlOverride
Definition SR.cs:1490
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string XmlHiddenMember
Definition SR.cs:1488
static string XmlIllegalTypedTextAttribute
Definition SR.cs:1676
Definition SR.cs:7
bool Declares(MemberMapping member, string parent)
void SetContentModel(TextAccessor text, bool hasElements)
MemberMapping FindDeclaringMapping(MemberMapping member, out StructMapping declaringMapping, string parent)