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

◆ ReadContentFromAsync() [2/2]

async ValueTask< bool > System.Xml.Linq.XContainer.ContentReader.ReadContentFromAsync ( XContainer rootContainer,
XmlReader r,
LoadOptions o )
inline

Definition at line 302 of file XContainer.cs.

303 {
304 XNode newNode = null;
305 string baseUri = r.BaseURI;
306 switch (r.NodeType)
307 {
308 case XmlNodeType.Element:
309 {
310 XElement e = new XElement(_eCache.Get(r.NamespaceURI).GetName(r.LocalName));
311 if (_baseUri != null && _baseUri != baseUri)
312 {
313 e.SetBaseUri(baseUri);
314 }
315 if (_lineInfo != null && _lineInfo.HasLineInfo())
316 {
318 }
319 if (r.MoveToFirstAttribute())
320 {
321 do
322 {
323 XName name = _aCache.Get((r.Prefix.Length == 0) ? string.Empty : r.NamespaceURI).GetName(r.LocalName);
324 XAttribute xAttribute = new XAttribute(name, await r.GetValueAsync().ConfigureAwait(continueOnCapturedContext: false));
325 if (_lineInfo != null && _lineInfo.HasLineInfo())
326 {
328 }
329 e.AppendAttributeSkipNotify(xAttribute);
330 }
331 while (r.MoveToNextAttribute());
332 r.MoveToElement();
333 }
335 if (!r.IsEmptyElement)
336 {
338 if (_baseUri != null)
339 {
340 _baseUri = baseUri;
341 }
342 }
343 break;
344 }
345 case XmlNodeType.EndElement:
346 if (_currentContainer.content == null)
347 {
348 _currentContainer.content = string.Empty;
349 }
350 if (_currentContainer is XElement xElement && _lineInfo != null && _lineInfo.HasLineInfo())
351 {
352 xElement.SetEndElementLineInfo(_lineInfo.LineNumber, _lineInfo.LinePosition);
353 }
355 {
356 return false;
357 }
359 {
361 }
363 break;
364 case XmlNodeType.Text:
365 case XmlNodeType.Whitespace:
366 case XmlNodeType.SignificantWhitespace:
367 {
368 if ((_baseUri != null && _baseUri != baseUri) || (_lineInfo != null && _lineInfo.HasLineInfo()))
369 {
370 newNode = new XText(await r.GetValueAsync().ConfigureAwait(continueOnCapturedContext: false));
371 break;
372 }
374 currentContainer.AddStringSkipNotify(await r.GetValueAsync().ConfigureAwait(continueOnCapturedContext: false));
375 break;
376 }
377 case XmlNodeType.CDATA:
378 newNode = new XCData(await r.GetValueAsync().ConfigureAwait(continueOnCapturedContext: false));
379 break;
380 case XmlNodeType.Comment:
381 newNode = new XComment(await r.GetValueAsync().ConfigureAwait(continueOnCapturedContext: false));
382 break;
383 case XmlNodeType.ProcessingInstruction:
384 {
385 string localName = r.Name;
386 newNode = new XProcessingInstruction(localName, await r.GetValueAsync().ConfigureAwait(continueOnCapturedContext: false));
387 break;
388 }
389 case XmlNodeType.DocumentType:
390 {
391 string localName = r.LocalName;
392 string attribute = r.GetAttribute("PUBLIC");
393 string attribute2 = r.GetAttribute("SYSTEM");
394 newNode = new XDocumentType(localName, attribute, attribute2, await r.GetValueAsync().ConfigureAwait(continueOnCapturedContext: false));
395 break;
396 }
397 case XmlNodeType.EntityReference:
398 if (!r.CanResolveEntity)
399 {
401 }
402 r.ResolveEntity();
403 break;
404 default:
406 case XmlNodeType.EndEntity:
407 break;
408 }
409 if (newNode != null)
410 {
411 if (_baseUri != null && _baseUri != baseUri)
412 {
413 newNode.SetBaseUri(baseUri);
414 }
415 if (_lineInfo != null && _lineInfo.HasLineInfo())
416 {
418 }
420 }
421 return true;
422 }
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string InvalidOperation_UnresolvedEntityReference
Definition SR.cs:60
static string InvalidOperation_UnexpectedNodeType
Definition SR.cs:58
Definition SR.cs:7
void AddNodeSkipNotify(XNode n)
XName GetName(string localName)
Definition XNamespace.cs:37
XContainer parent
Definition XObject.cs:7
XNamespace Get(string namespaceName)

References System.Xml.Linq.XContainer.ContentReader._aCache, System.Xml.Linq.XContainer.ContentReader._baseUri, System.Xml.Linq.XContainer.ContentReader._currentContainer, System.Xml.Linq.XContainer.ContentReader._eCache, System.Xml.Linq.XContainer.ContentReader._lineInfo, System.Xml.Linq.XContainer.AddNodeSkipNotify(), System.Xml.Linq.XElement.AppendAttributeSkipNotify(), System.Xml.Linq.XObject.BaseUri, System.Xml.Linq.XContainer.content, System.Xml.Dictionary, System.SR.Format(), System.Xml.Linq.NamespaceCache.Get(), System.Xml.Linq.XNamespace.GetName(), System.Xml.Linq.XObject.HasBaseUri, System.Xml.IXmlLineInfo.HasLineInfo(), System.SR.InvalidOperation_UnexpectedNodeType, System.SR.InvalidOperation_UnresolvedEntityReference, System.Xml.IXmlLineInfo.LineNumber, System.Xml.IXmlLineInfo.LinePosition, System.Xml.Linq.XObject.parent, System.Xml.Linq.XObject.SetBaseUri(), and System.Xml.Linq.XObject.SetLineInfo().