當前位置: 首頁>>代碼示例>>C#>>正文


C# XPathNavigator.ReadSubtree方法代碼示例

本文整理匯總了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);
            }
        }
開發者ID:hnlshzx,項目名稱:DotNetOpenAuth,代碼行數:33,代碼來源:PlatformsComponent.cs

示例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;
        }
開發者ID:csoltenborn,項目名稱:GoogleTestAdapter,代碼行數:12,代碼來源:RunSettingsService.cs

示例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);
		}
開發者ID:Orvid,項目名稱:NAntUniversalTasks,代碼行數:17,代碼來源:DefaultXmlSerializer.cs

示例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;
		}
開發者ID:ThatExtraBit,項目名稱:Castle.Core,代碼行數:22,代碼來源:DefaultXmlSerializer.cs

示例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");
		}
開發者ID:nobled,項目名稱:mono,代碼行數:23,代碼來源:XPathNavigatorReaderTests.cs

示例6: ReadSubtreeNamespace

		public void ReadSubtreeNamespace ()
		{
			string xml = "<root xmlns='urn:foo' />";
			nav = GetXmlDocumentNavigator (xml);
			nav.MoveToFirstChild ();
			nav.MoveToFirstNamespace ();
			nav.ReadSubtree ();
		}
開發者ID:nobled,項目名稱:mono,代碼行數:8,代碼來源:XPathNavigatorReaderTests.cs

示例7: ReadSubtreeAttribute

		public void ReadSubtreeAttribute ()
		{
			string xml = "<root a='b' />";
			nav = GetXmlDocumentNavigator (xml);
			nav.MoveToFirstChild ();
			nav.MoveToFirstAttribute ();
			nav.ReadSubtree ();
		}
開發者ID:nobled,項目名稱:mono,代碼行數:8,代碼來源:XPathNavigatorReaderTests.cs

示例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");
		}
開發者ID:nobled,項目名稱:mono,代碼行數:11,代碼來源:XPathNavigatorReaderTests.cs

示例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");
		}
開發者ID:nobled,項目名稱:mono,代碼行數:86,代碼來源:XPathNavigatorReaderTests.cs

示例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);
   }
 }
開發者ID:hkjensen,項目名稱:mediaportal-fanart-handler,代碼行數:56,代碼來源:Scraper.cs

示例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");
		}
開發者ID:nobled,項目名稱:mono,代碼行數:54,代碼來源:XPathNavigatorReaderTests.cs

示例12: Deserialize

 public static object Deserialize( Type type, XPathNavigator nav )
 {
     XmlSerializer serializer = new XmlSerializer( type );
     return serializer.Deserialize( nav.ReadSubtree() );
 }
開發者ID:hjarvard,項目名稱:ObjectXPathNavigator,代碼行數:5,代碼來源:NavigatorUtils.cs

示例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;
 }
開發者ID:jira-sarec,項目名稱:ICSE-2012-TraceLab,代碼行數:16,代碼來源:IOSpec.cs

示例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;
        }
開發者ID:CoEST,項目名稱:TraceLab,代碼行數:41,代碼來源:ExperimentFactoryReader.cs

示例15: ReadSubtreeComment

		public void ReadSubtreeComment ()
		{
			string xml = "<!-- comment --><root xmlns='urn:foo' />";
			nav = GetXmlDocumentNavigator (xml);
			nav.MoveToFirstChild ();
			nav.ReadSubtree ();
		}
開發者ID:nobled,項目名稱:mono,代碼行數:7,代碼來源:XPathNavigatorReaderTests.cs


注:本文中的System.Xml.XPath.XPathNavigator.ReadSubtree方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。