当前位置: 首页>>代码示例>>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;未经允许,请勿转载。