本文整理汇总了C#中XmlReader.ReadSubtree方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.ReadSubtree方法的具体用法?C# XmlReader.ReadSubtree怎么用?C# XmlReader.ReadSubtree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.ReadSubtree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Foo
private void Foo(XmlReader reader)
{
reader.Read();
Bar(reader.ReadSubtree());
}
示例2: _ParseValue
private dynamic _ParseValue(XmlReader reader)
{
string strToken;
if (_GetToken(reader, out strToken))
{
switch (strToken.ToLower())
{
case "true":
return true;
case "false":
return false;
case "string":
return reader.ReadString();
case "date":
return DateTime.Parse(reader.ReadString());
case "integer":
return Int64.Parse(reader.ReadString());
case "dict":
{
XmlReader sub = reader.ReadSubtree();
sub.MoveToContent();
PropertyList dict = new PropertyList();
dict._ParseDictionary(sub);
return dict;
}
case "array":
{
XmlReader sub = reader.ReadSubtree();
sub.MoveToContent();
List<PropertyList> list = new List<PropertyList>();
while (_NextToken(sub))
{
string strSubToken;
if (_GetToken(reader, out strSubToken) && strSubToken.ToLower() == "dict")
{
XmlReader subDict = reader.ReadSubtree();
subDict.MoveToContent();
PropertyList dict = new PropertyList();
dict._ParseDictionary(subDict);
list.Add(dict);
}
else
{
throw new FormatException("Invalid array -- we only support dictionaries");
}
}
return list;
}
case "data":
// TODO: we silently eat "data" elements, eventaully translate these into a object
break;
default:
{
throw new FormatException("Invalid type: " + reader.LocalName.ToLower());
}
}
}
return null;
}