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

  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:  PropertyToken
  18. **
  19. **
  20. ** Propertybuilder is for client to define properties for a 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 PropertyToken
  34.     {
  35.        
  36.         public static readonly PropertyToken Empty = new PropertyToken();
  37.        
  38.         internal int m_property;
  39.        
  40.         internal PropertyToken(int str)
  41.         {
  42.             m_property = str;
  43.         }
  44.        
  45.         public int Token {
  46.             get { return m_property; }
  47.         }
  48.        
  49.         // Satisfy value class requirements
  50.         public override int GetHashCode()
  51.         {
  52.             return m_property;
  53.         }
  54.        
  55.         // Satisfy value class requirements
  56.         public override bool Equals(object obj)
  57.         {
  58.             if (obj is PropertyToken)
  59.                 return Equals((PropertyToken)obj);
  60.             else
  61.                 return false;
  62.         }
  63.        
  64.         public bool Equals(PropertyToken obj)
  65.         {
  66.             return obj.m_property == m_property;
  67.         }
  68.        
  69.         public static bool operator ==(PropertyToken a, PropertyToken b)
  70.         {
  71.             return a.Equals(b);
  72.         }
  73.        
  74.         public static bool operator !=(PropertyToken a, PropertyToken b)
  75.         {
  76.             return !(a == b);
  77.         }
  78.        
  79.     }
  80.    
  81.    
  82. }

Developer Fusion