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


C# XPathExpression.Clone方法代碼示例

本文整理匯總了C#中System.Xml.XPath.XPathExpression.Clone方法的典型用法代碼示例。如果您正苦於以下問題:C# XPathExpression.Clone方法的具體用法?C# XPathExpression.Clone怎麽用?C# XPathExpression.Clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XPath.XPathExpression的用法示例。


在下文中一共展示了XPathExpression.Clone方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Select

        /// <summary>
        /// Selects a node set, using the specified XPath expression.
        /// </summary>
        /// <param name="navigator">A source XPathNavigator.</param>
        /// <param name="expression">An XPath expression.</param>
        /// <param name="variables">A set of XPathVariables.</param>
        /// <returns>An iterator over the nodes matching the specified expression.</returns>
        public static XPathNodeIterator Select(this XPathNavigator navigator, XPathExpression expression, params XPathVariable[] variables)
        {
            if (variables == null || variables.Length == 0 || variables[0] == null)
                return navigator.Select(expression);

            var compiled = expression.Clone(); // clone for thread-safety
            var context = new DynamicContext();
            foreach (var variable in variables)
                context.AddVariable(variable.Name, variable.Value);
            compiled.SetContext(context);
            return navigator.Select(compiled);
        }
開發者ID:CarlSargunar,項目名稱:Umbraco-CMS,代碼行數:19,代碼來源:XPathNavigatorExtensions.cs

示例2: Matches

		public bool Matches(XPathExpression xpath, XPathNavigator source)
		{
			xpath = (XPathExpression)xpath.Clone();
			xpath.SetContext(this);
			return source.Matches(xpath);
		}
開發者ID:n2cms,項目名稱:Castle.Core,代碼行數:6,代碼來源:XPathContext.cs

示例3: SelectSingleNode

		public XPathNavigator SelectSingleNode(XPathExpression xpath, XPathNavigator source)
		{
			xpath = (XPathExpression)xpath.Clone();
			xpath.SetContext(this);
			return source.SelectSingleNode(xpath);
		}
開發者ID:n2cms,項目名稱:Castle.Core,代碼行數:6,代碼來源:XPathContext.cs

示例4: Evaluate

		public bool Evaluate(XPathExpression xpath, XPathNavigator source, out object result)
		{
			xpath = (XPathExpression)xpath.Clone();
			xpath.SetContext(this);
			result = source.Evaluate(xpath);
			if (xpath.ReturnType == XPathResultType.NodeSet)	
			{
				if (((XPathNodeIterator)result).Count == 0)
					result = null;
			}
			return result != null;
		}
開發者ID:n2cms,項目名稱:Castle.Core,代碼行數:12,代碼來源:XPathContext.cs

示例5: EvalXPathExpr

 /// <summary>
 /// Returns the string result from evaluating an xpath expression against the given document and context.
 /// </summary>
 public static string EvalXPathExpr(IXPathNavigable doc, XPathExpression xpe, CustomContext c) {
     XPathExpression t = xpe.Clone();
     t.SetContext(c);
     return doc.CreateNavigator().Evaluate(t).ToString();
 }
開發者ID:Balamir,項目名稱:DotNetOpenAuth,代碼行數:8,代碼來源:BuildComponentUtilities.cs

示例6: EvalXPathExpr

        /// <summary>
        /// This is used to get the string result from evaluating an XPath expression against the given
        /// document and context.
        /// </summary>
        /// <param name="document">The document to use</param>
        /// <param name="expression">The XPath expression to evaluate</param>
        /// <param name="context">The context to use</param>
        /// <returns>The evaluated expression result</returns>
        /// <overloads>There are two overloads for this method</overloads>
        public static string EvalXPathExpr(this IXPathNavigable document, XPathExpression expression,
          CustomContext context)
        {
            XPathExpression t = expression.Clone();
            t.SetContext(context);

            return document.CreateNavigator().Evaluate(t).ToString();
        }
開發者ID:julianhaslinger,項目名稱:SHFB,代碼行數:17,代碼來源:BuildComponentUtilities.cs


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