Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
BaseValidator.cs
Go to the documentation of this file.
3using System.Text;
4
5namespace System.Xml.Schema;
6
7internal class BaseValidator
8{
10
12
13 private readonly XmlNameTable _nameTable;
14
16
17 private readonly PositionInfo _positionInfo;
18
20
21 private Uri _baseUri;
22
24
26
28
30
32
33 protected string textString;
34
35 protected bool hasSibling;
36
37 protected bool checkDatatype;
38
40
42
44
46 {
47 get
48 {
49 if (_schemaNames != null)
50 {
51 return _schemaNames;
52 }
53 if (_schemaCollection != null)
54 {
56 }
57 else
58 {
60 }
61 return _schemaNames;
62 }
63 }
64
66
68 {
69 get
70 {
71 return _xmlResolver;
72 }
73 set
74 {
76 }
77 }
78
79 public Uri BaseUri
80 {
81 get
82 {
83 return _baseUri;
84 }
85 set
86 {
88 }
89 }
90
91 public ValidationEventHandler EventHandler => (ValidationEventHandler)_eventHandling.EventHandler;
92
94
96 {
98 set
99 {
101 {
102 throw new XmlException(System.SR.Xml_InternalError, string.Empty);
103 }
105 }
106 }
107
108 public virtual bool PreserveWhitespace => false;
109
111 {
112 reader = other.reader;
113 _schemaCollection = other._schemaCollection;
114 _eventHandling = other._eventHandling;
115 _nameTable = other._nameTable;
116 _schemaNames = other._schemaNames;
117 _positionInfo = other._positionInfo;
118 _xmlResolver = other._xmlResolver;
119 _baseUri = other._baseUri;
120 elementName = other.elementName;
121 }
122
132
133 public virtual void Validate()
134 {
135 }
136
137 public virtual void CompleteValidation()
138 {
139 }
140
141 public virtual object FindId(string name)
142 {
143 return null;
144 }
145
146 public void ValidateText()
147 {
149 {
150 return;
151 }
152 if (context.IsNill)
153 {
155 return;
156 }
158 switch (contentValidator.ContentType)
159 {
160 case XmlSchemaContentType.ElementOnly:
161 {
162 ArrayList arrayList = contentValidator.ExpectedElements(context, isRequiredOnly: false);
163 if (arrayList == null)
164 {
166 break;
167 }
169 {
170 XmlSchemaValidator.BuildElementName(context.LocalName, context.Namespace),
171 XmlSchemaValidator.PrintExpectedElements(arrayList, getParticles: false)
172 });
173 break;
174 }
175 case XmlSchemaContentType.Empty:
177 break;
178 }
179 if (checkDatatype)
180 {
182 }
183 }
184
204
205 private void SaveTextValue(string value)
206 {
207 if (textString.Length == 0)
208 {
210 return;
211 }
212 if (!hasSibling)
213 {
215 hasSibling = true;
216 }
218 }
219
220 protected void SendValidationEvent(string code)
221 {
223 }
224
229
234
236 {
238 }
239
244
249
251 {
252 if (_eventHandling != null)
253 {
255 }
256 else if (severity == XmlSeverityType.Error)
257 {
258 throw e;
259 }
260 }
261
262 protected static void ProcessEntity(SchemaInfo sinfo, string name, object sender, ValidationEventHandler eventhandler, string baseUri, int lineNumber, int linePosition)
263 {
264 XmlSchemaException ex = null;
265 if (!sinfo.GeneralEntities.TryGetValue(new XmlQualifiedName(name), out var value))
266 {
267 ex = new XmlSchemaException(System.SR.Sch_UndeclaredEntity, name, baseUri, lineNumber, linePosition);
268 }
269 else if (value.NData.IsEmpty)
270 {
271 ex = new XmlSchemaException(System.SR.Sch_UnparsedEntityRef, name, baseUri, lineNumber, linePosition);
272 }
273 if (ex != null)
274 {
275 if (eventhandler == null)
276 {
277 throw ex;
278 }
279 eventhandler(sender, new ValidationEventArgs(ex));
280 }
281 }
282
283 protected static void ProcessEntity(SchemaInfo sinfo, string name, IValidationEventHandling eventHandling, string baseUriStr, int lineNumber, int linePosition)
284 {
285 string text = null;
286 if (!sinfo.GeneralEntities.TryGetValue(new XmlQualifiedName(name), out var value))
287 {
289 }
290 else if (value.NData.IsEmpty)
291 {
293 }
294 if (text != null)
295 {
296 XmlSchemaException ex = new XmlSchemaException(text, name, baseUriStr, lineNumber, linePosition);
297 if (eventHandling == null)
298 {
299 throw ex;
300 }
301 eventHandling.SendEvent(ex, XmlSeverityType.Error);
302 }
303 }
304
317}
static string Sch_InvalidTextInElementExpecting
Definition SR.cs:894
static string Sch_UndeclaredEntity
Definition SR.cs:748
static string Sch_ContentInNill
Definition SR.cs:784
static string Sch_InvalidTextInEmpty
Definition SR.cs:916
static string Xml_InternalError
Definition SR.cs:54
static string Sch_UnparsedEntityRef
Definition SR.cs:750
static string Sch_InvalidWhitespaceInEmpty
Definition SR.cs:918
static string Sch_InvalidTextInElement
Definition SR.cs:884
Definition SR.cs:7
StringBuilder Append(char value, int repeatCount)
static PositionInfo GetPositionInfo(object o)
void SendValidationEvent(string code, string msg, XmlSeverityType severity)
BaseValidator(BaseValidator other)
XmlSchemaCollection SchemaCollection
void SendValidationEvent(string code, string[] args, XmlSeverityType severity)
void SendValidationEvent(string code)
void SendValidationEvent(XmlSchemaException e, XmlSeverityType severity)
XmlValidatingReaderImpl reader
readonly PositionInfo _positionInfo
readonly XmlSchemaCollection _schemaCollection
void SendValidationEvent(string code, string[] args)
void SendValidationEvent(XmlSchemaException e)
readonly IValidationEventHandling _eventHandling
void SendValidationEvent(string code, string arg)
static BaseValidator CreateInstance(ValidationType valType, XmlValidatingReaderImpl reader, XmlSchemaCollection schemaCollection, IValidationEventHandling eventHandling, bool processIdentityConstraints)
virtual object FindId(string name)
static void ProcessEntity(SchemaInfo sinfo, string name, object sender, ValidationEventHandler eventhandler, string baseUri, int lineNumber, int linePosition)
BaseValidator(XmlValidatingReaderImpl reader, XmlSchemaCollection schemaCollection, IValidationEventHandling eventHandling)
static void ProcessEntity(SchemaInfo sinfo, string name, IValidationEventHandling eventHandling, string baseUriStr, int lineNumber, int linePosition)
readonly XmlNameTable _nameTable
SchemaNames GetSchemaNames(XmlNameTable nt)
static string BuildElementName(XmlQualifiedName qname)
static string QNameString(string localName, string ns)
void SendEvent(Exception exception, XmlSeverityType severity)
delegate void ValidationEventHandler(object? sender, ValidationEventArgs e)