The Labs \ Source Viewer \ SSCLI \ System.Xml.XPath \ XPathResultType

  1. //------------------------------------------------------------------------------
  2. // <copyright file="XPathExpr.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Xml.XPath
  16. {
  17.    
  18.     using System;
  19.     using System.Xml;
  20.     using System.Collections;
  21.     using MS.Internal.Xml.XPath;
  22.    
  23.     public enum XmlSortOrder
  24.     {
  25.         Ascending = 1,
  26.         Descending = 2
  27.     }
  28.    
  29.     public enum XmlCaseOrder
  30.     {
  31.         None = 0,
  32.         UpperFirst = 1,
  33.         LowerFirst = 2
  34.     }
  35.    
  36.     public enum XmlDataType
  37.     {
  38.         Text = 1,
  39.         Number = 2
  40.     }
  41.    
  42.     public enum XPathResultType
  43.     {
  44.         Number = 0,
  45.         String = 1,
  46.         Boolean = 2,
  47.         NodeSet = 3,
  48.         Navigator = XPathResultType.String,
  49.         Any = 5,
  50.         Error
  51.     }
  52.    
  53.     public abstract class XPathExpression
  54.     {
  55.         internal XPathExpression()
  56.         {
  57.         }
  58.        
  59.         public abstract string Expression {
  60.             get;
  61.         }
  62.        
  63.         public abstract void AddSort(object expr, IComparer comparer);
  64.        
  65.         public abstract void AddSort(object expr, XmlSortOrder order, XmlCaseOrder caseOrder, string lang, XmlDataType dataType);
  66.        
  67.         public abstract XPathExpression Clone();
  68.        
  69.         public abstract void SetContext(XmlNamespaceManager nsManager);
  70.        
  71.         public abstract void SetContext(IXmlNamespaceResolver nsResolver);
  72.        
  73.         public abstract XPathResultType ReturnType {
  74.             get;
  75.         }
  76.        
  77.         public static XPathExpression Compile(string xpath)
  78.         {
  79.                 /*nsResolver:*/            return Compile(xpath, null);
  80.         }
  81.        
  82.         public static XPathExpression Compile(string xpath, IXmlNamespaceResolver nsResolver)
  83.         {
  84.             bool hasPrefix;
  85.             Query query = new QueryBuilder().Build(xpath, out hasPrefix);
  86.             CompiledXpathExpr expr = new CompiledXpathExpr(query, xpath, hasPrefix);
  87.             if (null != nsResolver) {
  88.                 XmlNamespaceManager mngr = XPathNavigator.GetNamespaces(nsResolver);
  89.                 expr.SetContext(mngr);
  90.             }
  91.             return expr;
  92.         }
  93.        
  94.         private void PrintQuery(XmlWriter w)
  95.         {
  96.             ((CompiledXpathExpr)this).QueryTree.PrintQuery(w);
  97.         }
  98.     }
  99. }

Developer Fusion