本文整理汇总了C#中XmlReader.ResolveEntity方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ResolveEntity方法的具体用法?C# XmlReader.ResolveEntity怎么用?C# XmlReader.ResolveEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.ResolveEntity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadContentFrom
//.........这里部分代码省略.........
}
if (li != null && li.HasLineInfo())
{
e.SetLineInfo(li.LineNumber, li.LinePosition);
}
if (r.MoveToFirstAttribute())
{
do
{
XAttribute a = new XAttribute(aCache.Get(r.Prefix.Length == 0 ? string.Empty : r.NamespaceURI).GetName(r.LocalName), r.Value);
if (li != null && li.HasLineInfo())
{
a.SetLineInfo(li.LineNumber, li.LinePosition);
}
e.AppendAttributeSkipNotify(a);
} while (r.MoveToNextAttribute());
r.MoveToElement();
}
c.AddNodeSkipNotify(e);
if (!r.IsEmptyElement)
{
c = e;
if (baseUri != null)
{
baseUri = uri;
}
}
break;
}
case XmlNodeType.EndElement:
{
if (c.content == null)
{
c.content = string.Empty;
}
// Store the line info of the end element tag.
// Note that since we've got EndElement the current container must be an XElement
XElement e = c as XElement;
Debug.Assert(e != null, "EndElement received but the current container is not an element.");
if (e != null && li != null && li.HasLineInfo())
{
e.SetEndElementLineInfo(li.LineNumber, li.LinePosition);
}
if (c == this) return;
if (baseUri != null && c.HasBaseUri)
{
baseUri = c.parent.BaseUri;
}
c = c.parent;
break;
}
case XmlNodeType.Text:
case XmlNodeType.SignificantWhitespace:
case XmlNodeType.Whitespace:
if ((baseUri != null && baseUri != uri) ||
(li != null && li.HasLineInfo()))
{
n = new XText(r.Value);
}
else
{
c.AddStringSkipNotify(r.Value);
}
break;
case XmlNodeType.CDATA:
n = new XCData(r.Value);
break;
case XmlNodeType.Comment:
n = new XComment(r.Value);
break;
case XmlNodeType.ProcessingInstruction:
n = new XProcessingInstruction(r.Name, r.Value);
break;
case XmlNodeType.DocumentType:
n = new XDocumentType(r.LocalName, r.GetAttribute("PUBLIC"), r.GetAttribute("SYSTEM"), r.Value);
break;
case XmlNodeType.EntityReference:
if (!r.CanResolveEntity) throw new InvalidOperationException(SR.InvalidOperation_UnresolvedEntityReference);
r.ResolveEntity();
break;
case XmlNodeType.EndEntity:
break;
default:
throw new InvalidOperationException(SR.Format(SR.InvalidOperation_UnexpectedNodeType, r.NodeType));
}
if (n != null)
{
if (baseUri != null && baseUri != uri)
{
n.SetBaseUri(uri);
}
if (li != null && li.HasLineInfo())
{
n.SetLineInfo(li.LineNumber, li.LinePosition);
}
c.AddNodeSkipNotify(n);
n = null;
}
} while (r.Read());
}