Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ValidateNameInternal()

static bool System.Xml.ValidateNames.ValidateNameInternal ( string prefix,
string localName,
string ns,
XPathNodeType nodeKind,
Flags flags,
bool throwOnError )
inlinestaticprivate

Definition at line 273 of file ValidateNames.cs.

274 {
275 if ((flags & Flags.NCNames) != 0)
276 {
277 if (prefix.Length != 0 && !ParseNCNameInternal(prefix, throwOnError))
278 {
279 return false;
280 }
281 if (localName.Length != 0 && !ParseNCNameInternal(localName, throwOnError))
282 {
283 return false;
284 }
285 }
286 if ((flags & Flags.CheckLocalName) != 0)
287 {
288 if (nodeKind != XPathNodeType.Element)
289 {
290 if (nodeKind != XPathNodeType.Attribute)
291 {
292 if (nodeKind == XPathNodeType.ProcessingInstruction)
293 {
294 if (localName.Length == 0 || (localName.Length == 3 && StartsWithXml(localName)))
295 {
296 if (throwOnError)
297 {
298 throw new XmlException(System.SR.Xml_InvalidPIName, localName);
299 }
300 return false;
301 }
302 }
303 else if (localName.Length != 0)
304 {
305 if (throwOnError)
306 {
307 throw new XmlException(System.SR.XmlNoNameAllowed, nodeKind.ToString());
308 }
309 return false;
310 }
311 goto IL_00fa;
312 }
313 if (ns.Length == 0 && localName.Equals("xmlns"))
314 {
315 if (throwOnError)
316 {
317 throw new XmlException(System.SR.XmlBadName, new string[2]
318 {
319 nodeKind.ToString(),
320 localName
321 });
322 }
323 return false;
324 }
325 }
326 if (localName.Length == 0)
327 {
328 if (throwOnError)
329 {
330 throw new XmlException(System.SR.Xdom_Empty_LocalName, string.Empty);
331 }
332 return false;
333 }
334 }
335 goto IL_00fa;
336 IL_00fa:
337 if ((flags & Flags.CheckPrefixMapping) != 0)
338 {
339 switch (nodeKind)
340 {
341 case XPathNodeType.Element:
342 case XPathNodeType.Attribute:
343 case XPathNodeType.Namespace:
344 if (ns.Length == 0)
345 {
346 if (prefix.Length != 0)
347 {
348 if (throwOnError)
349 {
350 throw new XmlException(System.SR.Xml_PrefixForEmptyNs, string.Empty);
351 }
352 return false;
353 }
354 break;
355 }
356 if (prefix.Length == 0 && nodeKind == XPathNodeType.Attribute)
357 {
358 if (throwOnError)
359 {
360 throw new XmlException(System.SR.XmlBadName, new string[2]
361 {
362 nodeKind.ToString(),
363 localName
364 });
365 }
366 return false;
367 }
368 if (prefix.Equals("xml"))
369 {
370 if (!ns.Equals("http://www.w3.org/XML/1998/namespace"))
371 {
372 if (throwOnError)
373 {
374 throw new XmlException(System.SR.Xml_XmlPrefix, string.Empty);
375 }
376 return false;
377 }
378 break;
379 }
380 if (prefix.Equals("xmlns"))
381 {
382 if (throwOnError)
383 {
384 throw new XmlException(System.SR.Xml_XmlnsPrefix, string.Empty);
385 }
386 return false;
387 }
388 if (IsReservedNamespace(ns))
389 {
390 if (throwOnError)
391 {
392 throw new XmlException(System.SR.Xml_NamespaceDeclXmlXmlns, string.Empty);
393 }
394 return false;
395 }
396 break;
397 case XPathNodeType.ProcessingInstruction:
398 if (prefix.Length != 0 || ns.Length != 0)
399 {
400 if (throwOnError)
401 {
403 }
404 return false;
405 }
406 break;
407 default:
408 if (prefix.Length != 0 || ns.Length != 0)
409 {
410 if (throwOnError)
411 {
412 throw new XmlException(System.SR.XmlNoNameAllowed, nodeKind.ToString());
413 }
414 return false;
415 }
416 break;
417 }
418 }
419 return true;
420 }
static string Xml_PrefixForEmptyNs
Definition SR.cs:286
static string XmlBadName
Definition SR.cs:364
static string Xml_InvalidPIName
Definition SR.cs:90
static string Xml_XmlPrefix
Definition SR.cs:304
static string Xml_NamespaceDeclXmlXmlns
Definition SR.cs:308
static string XmlNoNameAllowed
Definition SR.cs:366
static string Xdom_Empty_LocalName
Definition SR.cs:1300
static string Xml_XmlnsPrefix
Definition SR.cs:306
Definition SR.cs:7
static bool ParseNCNameInternal(string s, bool throwOnError)
static bool IsReservedNamespace(string s)
static bool StartsWithXml(string s)
static string CreateName(string prefix, string localName)

References System.Xml.ValidateNames.CreateName(), System.Xml.Dictionary, System.Xml.ValidateNames.IsReservedNamespace(), System.Xml.ValidateNames.ParseNCNameInternal(), System.prefix, System.Xml.ValidateNames.StartsWithXml(), System.SR.Xdom_Empty_LocalName, System.SR.Xml_InvalidPIName, System.SR.Xml_NamespaceDeclXmlXmlns, System.SR.Xml_PrefixForEmptyNs, System.SR.Xml_XmlnsPrefix, System.SR.Xml_XmlPrefix, System.SR.XmlBadName, System.Xml.XmlException, and System.SR.XmlNoNameAllowed.

Referenced by System.Xml.ValidateNames.ValidateName(), and System.Xml.ValidateNames.ValidateNameThrow().