3 // Copyright (c) Microsoft Corporation. All rights reserved.
6 /*============================================================
10 ** <OWNER>Microsoft</OWNER>
13 ** Purpose: Represents a Field to the ILGenerator Class
16 ===========================================================*/
17 namespace System.Reflection.Emit {
20 using System.Reflection;
21 using System.Security.Permissions;
23 // The FieldToken class is an opaque representation of the Token returned
24 // by the Metadata to represent the field. FieldTokens are generated by
25 // Module.GetFieldToken(). There are no meaningful accessors on this class,
26 // but it can be passed to ILGenerator which understands it's internals.
28 [System.Runtime.InteropServices.ComVisible(true)]
29 public struct FieldToken
31 public static readonly FieldToken Empty = new FieldToken();
33 internal int m_fieldTok;
34 internal Object m_class;
36 // Creates an empty FieldToken. A publicly visible constructor so that
37 // it can be created on the stack.
38 //public FieldToken() {
43 // The actual constructor. Sets the field, attributes and class
46 internal FieldToken (int field, Type fieldClass) {
52 get { return m_fieldTok; }
56 // Generates the hash code for this field.
57 public override int GetHashCode()
62 // Returns true if obj is an instance of FieldToken and is
63 // equal to this instance.
64 public override bool Equals(Object obj)
66 if (obj is FieldToken)
67 return Equals((FieldToken)obj);
72 public bool Equals(FieldToken obj)
74 return obj.m_fieldTok == m_fieldTok && obj.m_class == m_class;
77 public static bool operator ==(FieldToken a, FieldToken b)
82 public static bool operator !=(FieldToken a, FieldToken b)