The Labs \ Source Viewer \ SSCLI \ System.Reflection.Emit \ TypeToken

  1. // ==++==
  2. //
  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. //
  14. // ==--==
  15. /*============================================================
  16. **
  17. ** Class:  TypeToken
  18. **
  19. **
  20. ** Purpose: Represents a Class to the ILGenerator class.
  21. **
  22. **
  23. ===========================================================*/
  24. namespace System.Reflection.Emit
  25. {
  26.    
  27.     using System;
  28.     using System.Reflection;
  29.     using System.Threading;
  30.     using System.Security.Permissions;
  31.    
  32.     [Serializable()]
  33.     [System.Runtime.InteropServices.ComVisible(true)]
  34.     public struct TypeToken
  35.     {
  36.        
  37.         public static readonly TypeToken Empty = new TypeToken();
  38.        
  39.         internal int m_class;
  40.        
  41.        
  42.         internal TypeToken(int str)
  43.         {
  44.             m_class = str;
  45.         }
  46.        
  47.         public int Token {
  48.             get { return m_class; }
  49.         }
  50.        
  51.         public override int GetHashCode()
  52.         {
  53.             return m_class;
  54.         }
  55.        
  56.         public override bool Equals(object obj)
  57.         {
  58.             if (obj is TypeToken)
  59.                 return Equals((TypeToken)obj);
  60.             else
  61.                 return false;
  62.         }
  63.        
  64.         public bool Equals(TypeToken obj)
  65.         {
  66.             return obj.m_class == m_class;
  67.         }
  68.        
  69.         public static bool operator ==(TypeToken a, TypeToken b)
  70.         {
  71.             return a.Equals(b);
  72.         }
  73.        
  74.         public static bool operator !=(TypeToken a, TypeToken b)
  75.         {
  76.             return !(a == b);
  77.         }
  78.        
  79.     }
  80. }

Developer Fusion