The Labs \ Source Viewer \ SSCLI \ System.Xml.Xsl.Xslt \ XsltAnnotation

  1. //------------------------------------------------------------------------------
  2. // <copyright file="XsltAnnotation.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.Reflection;
  17. using System.Xml.Xsl.Qil;
  18. namespace System.Xml.Xsl.Xslt
  19. {
  20.    
  21.     /// <summary>
  22.     /// Several annotations are created and attached to Qil nodes during Xslt compilation.
  23.     /// </summary>
  24.     internal class XsltAnnotation : ListBase<object>
  25.     {
  26.         private object arg0, arg1, arg2;
  27.        
  28.        
  29.         //-----------------------------------------------
  30.         // Constructor
  31.         //-----------------------------------------------
  32.        
  33.         /// <summary>
  34.         /// Create and initialize XsltAnnotation for the specified node.
  35.         /// Allow properties to be read and written.
  36.         /// </summary>
  37.         public static XsltAnnotation Write(QilNode nd)
  38.         {
  39.             XsltAnnotation ann = nd.Annotation as XsltAnnotation;
  40.            
  41.             if (ann == null) {
  42.                 ann = new XsltAnnotation();
  43.                 nd.Annotation = ann;
  44.             }
  45.            
  46.             return ann;
  47.         }
  48.        
  49.         private XsltAnnotation()
  50.         {
  51.         }
  52.        
  53.        
  54.         //-----------------------------------------------
  55.         // ListBase implementation
  56.         //-----------------------------------------------
  57.        
  58.         /// <summary>
  59.         /// List of annotations can be updated.
  60.         /// </summary>
  61.         public override bool IsReadOnly {
  62.             get { return false; }
  63.         }
  64.        
  65.         /// <summary>
  66.         /// Return the count of sub-annotations maintained by this annotation.
  67.         /// </summary>
  68.         public override int Count {
  69.             get { return 3; }
  70.         }
  71.        
  72.         /// <summary>
  73.         /// Return the annotation at the specified index.
  74.         /// </summary>
  75.         public override object this[int index]
  76.         {
  77.             get {
  78.                 switch (index) {
  79.                     case 0:
  80.                         return this.arg0;
  81.                     case 1:
  82.                         return this.arg1;
  83.                     case 2:
  84.                         return this.arg2;
  85.                 }
  86.                
  87.                 throw new IndexOutOfRangeException();
  88.             }
  89.             set {
  90.                 switch (index) {
  91.                     case 0:
  92.                         this.arg0 = value;
  93.                         return;
  94.                     case 1:
  95.                         this.arg1 = value;
  96.                         return;
  97.                     case 2:
  98.                         this.arg2 = value;
  99.                         return;
  100.                 }
  101.                 throw new IndexOutOfRangeException();
  102.             }
  103.         }
  104.     }
  105. }

Developer Fusion