The Labs \ Source Viewer \ SSCLI \ System.Xml.Xsl.Qil \ QilLiteral

  1. //------------------------------------------------------------------------------
  2. // <copyright file="QilLiteral.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. using System;
  16. using System.Diagnostics;
  17. namespace System.Xml.Xsl.Qil
  18. {
  19.    
  20.     /// <summary>
  21.     /// View over a Qil atomic value literal (of any type).
  22.     /// </summary>
  23.     /// <remarks>
  24.     /// Don't construct QIL nodes directly; instead, use the <see cref="QilFactory">QilFactory</see>.
  25.     /// </remarks>
  26.     internal class QilLiteral : QilNode
  27.     {
  28.         private object value;
  29.        
  30.        
  31.         //-----------------------------------------------
  32.         // Constructor
  33.         //-----------------------------------------------
  34.        
  35.         /// <summary>
  36.         /// Construct a new node
  37.         /// </summary>
  38.         public QilLiteral(QilNodeType nodeType, object value) : base(nodeType)
  39.         {
  40.             Value = value;
  41.         }
  42.        
  43.        
  44.         //-----------------------------------------------
  45.         // QilLiteral methods
  46.         //-----------------------------------------------
  47.        
  48.         public object Value {
  49.             get { return this.value; }
  50.             set { this.value = value; }
  51.         }
  52.        
  53.         public static implicit operator string(QilLiteral literal)
  54.         {
  55.             return (string)literal.value;
  56.         }
  57.        
  58.         public static implicit operator int(QilLiteral literal)
  59.         {
  60.             return (int)literal.value;
  61.         }
  62.        
  63.         public static implicit operator long(QilLiteral literal)
  64.         {
  65.             return (long)literal.value;
  66.         }
  67.        
  68.         public static implicit operator double(QilLiteral literal)
  69.         {
  70.             return (double)literal.value;
  71.         }
  72.        
  73.         public static implicit operator decimal(QilLiteral literal)
  74.         {
  75.             return (decimal)literal.value;
  76.         }
  77.        
  78.         public static implicit operator XmlQueryType(QilLiteral literal)
  79.         {
  80.             return (XmlQueryType)literal.value;
  81.         }
  82.     }
  83. }

Developer Fusion