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

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

Developer Fusion