本文整理汇总了C#中System.Xml.XPath.XPathNavigator.ReadSubtree方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNavigator.ReadSubtree方法的具体用法?C# XPathNavigator.ReadSubtree怎么用?C# XPathNavigator.ReadSubtree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathNavigator
的用法示例。
在下文中一共展示了XPathNavigator.ReadSubtree方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPlatformVersionFilter
private void AddPlatformVersionFilter(string platformId, string versionId, XPathNavigator platformNode, string file)
{
Dictionary<string, VersionFilter> platformFrameworks;
if (!versionFilters.TryGetValue(platformId, out platformFrameworks))
{
platformFrameworks = new Dictionary<string, VersionFilter>();
versionFilters.Add(platformId, platformFrameworks);
}
try
{
VersionFilter filter;
XmlReader platformReader = platformNode.ReadSubtree();
platformReader.MoveToContent();
if (!platformFrameworks.TryGetValue(versionId, out filter))
{
filter = new VersionFilter(platformReader, versionId, file);
}
else
{
// if the platform already has a filter for this version, add the data from the current platform node
filter.AddPlatformNode(platformReader, file);
}
platformReader.Close();
platformFrameworks.Remove(versionId);
platformFrameworks.Add(versionId, filter);
}
catch (Exception e)
{
WriteMessage(MessageLevel.Error, e.Message);
}
}
示例2: CopyToUnsetValues
private bool CopyToUnsetValues(XPathNavigator sourceNavigator, RunSettings targetRunSettings)
{
if (sourceNavigator.MoveToChild(GoogleTestConstants.SettingsName, ""))
{
RunSettings sourceRunSettings = RunSettings.LoadFromXml(sourceNavigator.ReadSubtree());
targetRunSettings.GetUnsetValuesFrom(sourceRunSettings);
return true;
}
return false;
}
示例3: ReadObject
public bool ReadObject(XPathResult result, XPathNavigator node, out object value)
{
using (var reader = node.ReadSubtree())
{
reader.MoveToContent();
if (typeof(IXmlSerializable).IsAssignableFrom(result.Type))
{
value = DeserializeCustom(reader, result, node);
}
else
{
value = Deserialize(reader, result, node);
}
}
return (value != null);
}
示例4: ReadObject
public bool ReadObject(XPathResult result, XPathNavigator node, out object value)
{
var rootOverride = new XmlRootAttribute(node.LocalName)
{
Namespace = node.NamespaceURI
};
var serializer = new XmlSerializer(result.Type, rootOverride);
using (var reader = node.ReadSubtree())
{
reader.MoveToContent();
if (serializer.CanDeserialize(reader))
{
value = serializer.Deserialize(reader);
return true;
}
}
value = null;
return false;
}
示例5: ReadSubtree1
void ReadSubtree1 (XPathNavigator nav, string label)
{
XmlReader r = nav.ReadSubtree ();
XmlAssert.AssertNode (label + "#1", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.None, 0, false,
// Name, Prefix, LocalName, NamespaceURI
String.Empty, String.Empty, String.Empty, String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
String.Empty, false, 0, false);
Assert.IsTrue (r.Read (), label + "#2");
XmlAssert.AssertNode (label + "#3", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.Element, 0, true,
// Name, Prefix, LocalName, NamespaceURI
"root", String.Empty, "root", String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
String.Empty, false, 0, false);
Assert.IsFalse (r.Read (), label + "#4");
}
示例6: ReadSubtreeNamespace
public void ReadSubtreeNamespace ()
{
string xml = "<root xmlns='urn:foo' />";
nav = GetXmlDocumentNavigator (xml);
nav.MoveToFirstChild ();
nav.MoveToFirstNamespace ();
nav.ReadSubtree ();
}
示例7: ReadSubtreeAttribute
public void ReadSubtreeAttribute ()
{
string xml = "<root a='b' />";
nav = GetXmlDocumentNavigator (xml);
nav.MoveToFirstChild ();
nav.MoveToFirstAttribute ();
nav.ReadSubtree ();
}
示例8: MoveToFirstAttributeFromAttribute
void MoveToFirstAttributeFromAttribute (XPathNavigator nav, string label)
{
XmlReader r = nav.ReadSubtree ();
r.MoveToContent ();
Assert.IsTrue (r.MoveToFirstAttribute (), label + "#1");
Assert.IsTrue (r.MoveToFirstAttribute (), label + "#2");
r.ReadAttributeValue ();
Assert.IsTrue (r.MoveToFirstAttribute (), label + "#3");
Assert.IsTrue (r.MoveToNextAttribute (), label + "#4");
Assert.IsTrue (r.MoveToFirstAttribute (), label + "#5");
}
示例9: MixedContentAndDepth
void MixedContentAndDepth (XPathNavigator nav, string label)
{
XmlReader r = nav.ReadSubtree ();
r.Read ();
XmlAssert.AssertNode (label + "#1", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.Element, 0, false,
// Name, Prefix, LocalName, NamespaceURI
"one", String.Empty, "one", String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
String.Empty, false, 0, false);
r.Read ();
XmlAssert.AssertNode (label + "#2", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.Element, 1, false,
// Name, Prefix, LocalName, NamespaceURI
"two", String.Empty, "two", String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
String.Empty, false, 0, false);
r.Read ();
XmlAssert.AssertNode (label + "#3", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.Text, 2, false,
// Name, Prefix, LocalName, NamespaceURI
String.Empty, String.Empty, String.Empty, String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
"Some data.", true, 0, false);
r.Read ();
XmlAssert.AssertNode (label + "#4", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.Element, 2, false,
// Name, Prefix, LocalName, NamespaceURI
"three", String.Empty, "three", String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
String.Empty, false, 0, false);
r.Read ();
XmlAssert.AssertNode (label + "#5", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.Text, 3, false,
// Name, Prefix, LocalName, NamespaceURI
String.Empty, String.Empty, String.Empty, String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
"more", true, 0, false);
r.Read ();
XmlAssert.AssertNode (label + "#6", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.EndElement, 2, false,
// Name, Prefix, LocalName, NamespaceURI
"three", String.Empty, "three", String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
String.Empty, false, 0, false);
r.Read ();
XmlAssert.AssertNode (label + "#7", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.Text, 2, false,
// Name, Prefix, LocalName, NamespaceURI
String.Empty, String.Empty, String.Empty, String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
" done.", true, 0, false);
r.Read ();
XmlAssert.AssertNode (label + "#8", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.EndElement, 1, false,
// Name, Prefix, LocalName, NamespaceURI
"two", String.Empty, "two", String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
String.Empty, false, 0, false);
r.Read ();
XmlAssert.AssertNode (label + "#9", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.EndElement, 0, false,
// Name, Prefix, LocalName, NamespaceURI
"one", String.Empty, "one", String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
String.Empty, false, 0, false);
Assert.IsFalse (r.Read (), label + "#10");
}
示例10: GetNodeInfo
// Begin: GetNodeInfo
private void GetNodeInfo(XPathNavigator nav1)
{
if (nav1 != null && nav1.Name != null && nav1.Name.ToString(CultureInfo.CurrentCulture).Equals("images", StringComparison.CurrentCulture))
{
using (var xmlReader = nav1.ReadSubtree())
{
var searchResults = new SearchResults();
while (xmlReader.Read())
{
if (xmlReader.NodeType == XmlNodeType.Element)
{
switch (xmlReader.Name)
{
case "id":
searchResults = new SearchResults();
searchResults.Id = xmlReader.ReadString();
continue;
case "album":
searchResults.Album = xmlReader.ReadString();
continue;
case "title":
searchResults.Title = xmlReader.ReadString();
continue;
case "alias":
searchResults.AddAlias(xmlReader.ReadString());
continue;
case "mbid":
searchResults.MBID = xmlReader.ReadString();
continue;
case "votes":
alSearchResults.Add(searchResults);
continue;
default:
continue;
}
}
}
}
}
if (nav1 != null && nav1.HasChildren)
{
nav1.MoveToFirstChild();
while (nav1.MoveToNext())
{
GetNodeInfo(nav1);
nav1.MoveToParent();
}
}
else
{
if (nav1 == null || !nav1.MoveToNext())
return;
GetNodeInfo(nav1);
}
}
示例11: DocElem_OpenClose_Attribute
void DocElem_OpenClose_Attribute (XPathNavigator nav, string label)
{
XmlReader r = nav.ReadSubtree ();
XmlAssert.AssertNode (label + "#1", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.None, 0, false,
// Name, Prefix, LocalName, NamespaceURI
String.Empty, String.Empty, String.Empty, String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
String.Empty, false, 0, false);
Assert.IsTrue (r.Read (), label + "#2");
XmlAssert.AssertNode (label + "#3", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.Element, 0, false,
// Name, Prefix, LocalName, NamespaceURI
"root", String.Empty, "root", String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
String.Empty, false, 1, true);
Assert.IsTrue (r.MoveToFirstAttribute (), label + "#4");
XmlAssert.AssertNode (label + "#5", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.Attribute, 1, false,
// Name, Prefix, LocalName, NamespaceURI
"attr", String.Empty, "attr", String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
"value", true, 1, true);
Assert.IsTrue (r.ReadAttributeValue (), label + "#6");
XmlAssert.AssertNode (label + "#7", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.Text, 2, false,
// Name, Prefix, LocalName, NamespaceURI
String.Empty, String.Empty, String.Empty, String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
"value", true, 1, true);
Assert.IsFalse (r.ReadAttributeValue (), label + "#8");
Assert.IsFalse (r.MoveToNextAttribute (), label + "#9");
Assert.IsTrue (r.MoveToElement (), label + "#10");
Assert.IsTrue (r.Read (), label + "#11");
XmlAssert.AssertNode (label + "#12", r,
// NodeType, Depth, IsEmptyElement
XmlNodeType.EndElement, 0, false,
// Name, Prefix, LocalName, NamespaceURI
"root", String.Empty, "root", String.Empty,
// Value, HasValue, AttributeCount, HasAttributes
String.Empty, false, 0, false);
Assert.IsFalse (r.Read (), label + "#13");
}
示例12: Deserialize
public static object Deserialize( Type type, XPathNavigator nav )
{
XmlSerializer serializer = new XmlSerializer( type );
return serializer.Deserialize( nav.ReadSubtree() );
}
示例13: ReadIOSpec
/// <summary>
/// Reads the IO spec.
/// </summary>
/// <param name="nav">A cursor in the xml data</param>
/// <returns></returns>
internal static IOSpec ReadIOSpec(XPathNavigator nav)
{
IOSpec temporaryIOSpec = new IOSpec();
if (nav != null)
{
var reader = nav.ReadSubtree();
reader.Read();
temporaryIOSpec.ReadXml(reader);
}
return temporaryIOSpec;
}
示例14: EdgeFactory
/// <summary>
/// Constructs experiment node connection from given xml xpath navigator to the edge.
/// </summary>
/// <param name="reader">The reader with edge root.</param>
/// <returns>experiment node connection</returns>
public ExperimentNodeConnection EdgeFactory(XPathNavigator reader)
{
string id = reader.GetAttribute("id", String.Empty);
string source = reader.GetAttribute("source", String.Empty);
string target = reader.GetAttribute("target", String.Empty);
//try read is fixed attribute
string isFixedAttrib = reader.GetAttribute("isFixed", String.Empty);
bool isFixed;
if (!Boolean.TryParse(isFixedAttrib, out isFixed)) isFixed = false;
//try read is visible attribute
string isVisibleAttrib = reader.GetAttribute("isVisible", String.Empty);
bool isVisible;
if (!Boolean.TryParse(isVisibleAttrib, out isVisible)) isVisible = true;
//validate
if (m_vertices.ContainsKey(source) == false || m_vertices.ContainsKey(target) == false)
{
throw new TraceLab.Core.Exceptions.ExperimentLoadException("The experiment is corrupted and could not be loaded. Experiment xml contains edge that refers to non-existing nodes.");
}
ExperimentNode sourceVert = m_vertices[source];
ExperimentNode targetVert = m_vertices[target];
ExperimentNodeConnection edge = new ExperimentNodeConnection(id, sourceVert, targetVert, isFixed, isVisible);
edge.IsModified = false;
m_edges[id] = edge;
//read in route points from xml
edge.RoutePoints.ReadXml(reader.ReadSubtree());
//perform fixes for scopes
ScopeNodeHelper.TryFixScopeDecisionEntryAndExitNodes(sourceVert, targetVert);
return edge;
}
示例15: ReadSubtreeComment
public void ReadSubtreeComment ()
{
string xml = "<!-- comment --><root xmlns='urn:foo' />";
nav = GetXmlDocumentNavigator (xml);
nav.MoveToFirstChild ();
nav.ReadSubtree ();
}