The Labs \ Source Viewer \ SSCLI \ System.Xml.Xsl.Runtime \ EarlyBoundInfo

  1. //------------------------------------------------------------------------------
  2. // <copyright file="EarlyBoundInfo.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. using System.Reflection;
  18. namespace System.Xml.Xsl.Runtime
  19. {
  20.    
  21.     /// <summary>
  22.     /// This class contains information about early bound function objects.
  23.     /// </summary>
  24.     internal sealed class EarlyBoundInfo
  25.     {
  26.         private string namespaceUri;
  27.         // Namespace Uri mapped to these early bound functions
  28.         private ConstructorInfo constrInfo;
  29.         // Constructor for the early bound function object
  30.         public EarlyBoundInfo(string namespaceUri, ConstructorInfo constrInfo)
  31.         {
  32.             Debug.Assert(namespaceUri != null && constrInfo != null);
  33.             this.namespaceUri = namespaceUri;
  34.             this.constrInfo = constrInfo;
  35.         }
  36.        
  37.         /// <summary>
  38.         /// Get the Namespace Uri mapped to these early bound functions.
  39.         /// </summary>
  40.         public string NamespaceUri {
  41.             get { return this.namespaceUri; }
  42.         }
  43.        
  44.         /// <summary>
  45.         /// Return the Clr Type of the early bound object
  46.         /// </summary>
  47.         public Type EarlyBoundType {
  48.             get { return this.constrInfo.DeclaringType; }
  49.         }
  50.        
  51.         /// <summary>
  52.         /// Create an instance of the early bound object.
  53.         /// </summary>
  54.         public object CreateObject()
  55.         {
  56.             return this.constrInfo.Invoke(new object[] {});
  57.         }
  58.        
  59.         /// <summary>
  60.         /// Override Equals method so that EarlyBoundInfo to implement value comparison.
  61.         /// </summary>
  62.         public override bool Equals(object obj)
  63.         {
  64.             EarlyBoundInfo info = obj as EarlyBoundInfo;
  65.             if (info == null)
  66.                 return false;
  67.            
  68.             return this.namespaceUri == info.namespaceUri && this.constrInfo == info.constrInfo;
  69.         }
  70.        
  71.         /// <summary>
  72.         /// Override GetHashCode since Equals is overriden.
  73.         /// </summary>
  74.         public override int GetHashCode()
  75.         {
  76.             return this.namespaceUri.GetHashCode();
  77.         }
  78.     }
  79. }

Developer Fusion