public object Evaluate <T>(XNode node, string expression, IXmlNamespaceResolver resolver) where T : class
        {
            object obj2 = node.CreateNavigator().Evaluate(expression, resolver);

            if (obj2 is XPathNodeIterator)
            {
                return(this.EvaluateIterator <T>((XPathNodeIterator)obj2));
            }
            if (!(obj2 is T))
            {
                throw new InvalidOperationException(System.Xml.Linq.Res.GetString("InvalidOperation_UnexpectedEvaluation", new object[] { obj2.GetType() }));
            }
            return((T)obj2);
        }
Пример #2
0
        public object Evaluate <T>(XNode node, string expression, IXmlNamespaceResolver resolver) where T : class
        {
            XPathNavigator navigator = node.CreateNavigator();
            object         result    = navigator.Evaluate(expression, resolver);

            if (result is XPathNodeIterator)
            {
                return(EvaluateIterator <T>((XPathNodeIterator)result));
            }
            if (!(result is T))
            {
                throw new InvalidOperationException(SR.Format(SR.InvalidOperation_UnexpectedEvaluation, result.GetType()));
            }
            return((T)result);
        }
Пример #3
0
 /// <summary>
 /// Creates an <see cref="XPathNavigator"/> for a given <see cref="XNode"/>
 /// </summary>
 /// <param name="node">Extension point <see cref="XNode"/></param>
 /// <returns>An <see cref="XPathNavigator"/></returns>
 public static XPathNavigator CreateNavigator(this XNode node)
 {
     return(node.CreateNavigator(null));
 }
Пример #4
0
 public XPathNavigator CreateNavigator()
 {
     return(_node.CreateNavigator());
 }