Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SchemaInfo.cs
Go to the documentation of this file.
2
3namespace System.Xml.Schema;
4
5internal sealed class SchemaInfo : IDtdInfo
6{
8
10
12
14
16
17 private string _internalDtdSubset = string.Empty;
18
20
22
24
26
27 private int _errorCount;
28
30
32
34
36 {
37 get
38 {
39 return _docTypeName;
40 }
41 set
42 {
44 }
45 }
46
47 internal string InternalDtdSubset
48 {
49 set
50 {
52 }
53 }
54
56
58
70
82
84 {
85 get
86 {
87 return _schemaType;
88 }
89 set
90 {
92 }
93 }
94
96
98
100
102 {
103 get
104 {
105 if (_notations == null)
106 {
108 }
109 return _notations;
110 }
111 }
112
113 internal int ErrorCount
114 {
115 get
116 {
117 return _errorCount;
118 }
119 set
120 {
122 }
123 }
124
126
128
130
132
133 internal SchemaInfo()
134 {
135 _schemaType = SchemaType.None;
136 }
137
139 {
141 {
142 return value;
143 }
144 return null;
145 }
146
148 {
150 {
151 return value;
152 }
153 return null;
154 }
155
157 {
158 return GetElementDecl(qname)?.SchemaElement;
159 }
160
161 internal bool HasSchema(string ns)
162 {
164 }
165
166 internal bool Contains(string ns)
167 {
169 }
170
172 {
173 SchemaAttDef value = null;
174 if (ed != null)
175 {
176 value = ed.GetAttDef(qname);
177 if (value == null)
178 {
179 if (!ed.ContentValidator.IsOpen || qname.Namespace.Length == 0)
180 {
182 }
184 {
186 }
187 }
188 }
189 return value;
190 }
191
193 {
194 SchemaAttDef value = null;
195 attributeMatchState = AttributeMatchState.UndeclaredAttribute;
196 if (ed != null)
197 {
198 value = ed.GetAttDef(qname);
199 if (value != null)
200 {
202 return value;
203 }
205 if (anyAttribute != null)
206 {
207 if (!anyAttribute.NamespaceList.Allows(qname))
208 {
209 attributeMatchState = AttributeMatchState.ProhibitedAnyAttribute;
210 }
211 else if (anyAttribute.ProcessContentsCorrect != XmlSchemaContentProcessing.Skip)
212 {
214 {
215 if (value.Datatype.TypeCode == XmlTypeCode.Id)
216 {
217 attributeMatchState = AttributeMatchState.AnyIdAttributeFound;
218 }
219 else
220 {
222 }
223 }
224 else if (anyAttribute.ProcessContentsCorrect == XmlSchemaContentProcessing.Lax)
225 {
227 }
228 }
229 else
230 {
231 attributeMatchState = AttributeMatchState.AnyAttributeSkip;
232 }
233 }
234 else if (ed.ProhibitedAttributes.ContainsKey(qname))
235 {
236 attributeMatchState = AttributeMatchState.ProhibitedAttribute;
237 }
238 }
239 else if (partialValidationType != null)
240 {
242 {
243 if (qname.Equals(xmlSchemaAttribute.QualifiedName))
244 {
245 value = xmlSchemaAttribute.AttDef;
247 }
248 else
249 {
250 attributeMatchState = AttributeMatchState.AttributeNameMismatch;
251 }
252 }
253 else
254 {
255 attributeMatchState = AttributeMatchState.ValidateAttributeInvalidCall;
256 }
257 }
258 else if (_attributeDecls.TryGetValue(qname, out value))
259 {
261 }
262 else
263 {
264 attributeMatchState = AttributeMatchState.UndeclaredElementAndAttribute;
265 }
266 return value;
267 }
268
270 {
273 switch (attributeMatchState)
274 {
275 case AttributeMatchState.UndeclaredAttribute:
277 case AttributeMatchState.ProhibitedAnyAttribute:
278 case AttributeMatchState.ProhibitedAttribute:
280 case AttributeMatchState.AnyAttributeSkip:
281 skip = true;
282 break;
283 }
284 return attributeXsd;
285 }
286
287 internal void Add(SchemaInfo sinfo, ValidationEventHandler eventhandler)
288 {
289 if (_schemaType == SchemaType.None)
290 {
291 _schemaType = sinfo.SchemaType;
292 }
293 else if (_schemaType != sinfo.SchemaType)
294 {
295 eventhandler?.Invoke(this, new ValidationEventArgs(new XmlSchemaException(System.SR.Sch_MixSchemaTypes, string.Empty)));
296 return;
297 }
298 foreach (string key in sinfo.TargetNamespaces.Keys)
299 {
301 {
303 }
304 }
306 {
308 {
310 }
311 }
312 foreach (KeyValuePair<XmlQualifiedName, SchemaElementDecl> item in sinfo._elementDeclsByType)
313 {
315 {
316 _elementDeclsByType.Add(item.Key, item.Value);
317 }
318 }
319 foreach (SchemaAttDef value in sinfo.AttributeDecls.Values)
320 {
322 {
324 }
325 }
326 foreach (SchemaNotation value2 in sinfo.Notations.Values)
327 {
328 if (!Notations.ContainsKey(value2.Name.Name))
329 {
330 Notations.Add(value2.Name.Name, value2);
331 }
332 }
333 }
334
335 internal void Finish()
336 {
338 for (int i = 0; i < 2; i++)
339 {
341 {
342 if (value.HasNonCDataAttribute)
343 {
345 }
346 if (value.DefaultAttDefs != null)
347 {
349 }
350 }
352 }
353 }
354
356 {
359 {
361 }
362 return value;
363 }
364
372
374 {
375 if (_generalEntities == null)
376 {
377 return null;
378 }
381 {
382 return value;
383 }
384 return null;
385 }
386}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
void Add(TKey key, TValue value)
static string Sch_MixSchemaTypes
Definition SR.cs:1122
static string Sch_ProhibitedAttribute
Definition SR.cs:950
static string Sch_UndeclaredAttribute
Definition SR.cs:414
Definition SR.cs:7
readonly Dictionary< XmlQualifiedName, SchemaAttDef > _attributeDecls
Definition SchemaInfo.cs:25
Dictionary< XmlQualifiedName, SchemaElementDecl > ElementDeclsByType
Definition SchemaInfo.cs:97
Dictionary< XmlQualifiedName, SchemaEntity > _generalEntities
Definition SchemaInfo.cs:11
SchemaElementDecl GetElementDecl(XmlQualifiedName qname)
SchemaElementDecl GetTypeDecl(XmlQualifiedName qname)
SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, ref bool skip)
readonly Dictionary< XmlQualifiedName, SchemaElementDecl > _elementDecls
Definition SchemaInfo.cs:7
XmlSchemaElement GetElement(XmlQualifiedName qname)
Dictionary< XmlQualifiedName, SchemaAttDef > AttributeDecls
Definition SchemaInfo.cs:99
Dictionary< XmlQualifiedName, SchemaEntity > GeneralEntities
Definition SchemaInfo.cs:60
readonly Dictionary< string, bool > _targetNamespaces
Definition SchemaInfo.cs:23
Dictionary< string, SchemaNotation > Notations
Dictionary< XmlQualifiedName, SchemaEntity > ParameterEntities
Definition SchemaInfo.cs:72
readonly Dictionary< XmlQualifiedName, SchemaElementDecl > _elementDeclsByType
Definition SchemaInfo.cs:31
SchemaAttDef GetAttributeXdr(SchemaElementDecl ed, XmlQualifiedName qname)
void Add(SchemaInfo sinfo, ValidationEventHandler eventhandler)
readonly Dictionary< XmlQualifiedName, SchemaElementDecl > _undeclaredElementDecls
Definition SchemaInfo.cs:9
XmlQualifiedName _docTypeName
Definition SchemaInfo.cs:15
Dictionary< XmlQualifiedName, SchemaElementDecl > ElementDecls
Definition SchemaInfo.cs:55
XmlQualifiedName DocTypeName
Definition SchemaInfo.cs:36
SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, XmlSchemaObject partialValidationType, out AttributeMatchState attributeMatchState)
Dictionary< string, SchemaNotation > _notations
Definition SchemaInfo.cs:33
Dictionary< string, bool > TargetNamespaces
Definition SchemaInfo.cs:95
Dictionary< XmlQualifiedName, SchemaElementDecl > UndeclaredElementDecls
Definition SchemaInfo.cs:57
Dictionary< XmlQualifiedName, SchemaEntity > _parameterEntities
Definition SchemaInfo.cs:13
override bool Equals([NotNullWhen(true)] object? other)
static readonly XmlQualifiedName Empty
IDtdEntityInfo LookupEntity(string name)
IDtdAttributeListInfo LookupAttributeList(string prefix, string localName)
IEnumerable< IDtdAttributeListInfo > GetAttributeLists()