Struct MetadataToken
- Namespace
- AsmResolver.PE.DotNet.Metadata.Tables
- Assembly
- AsmResolver.PE.dll
Represents a metadata token, referencing a member using a table and a row index.
public readonly struct MetadataToken : IComparable<MetadataToken>
- Implements
- Inherited Members
Constructors
MetadataToken(TableIndex, uint)
Creates a new metadata token from a table index and a row index.
public MetadataToken(TableIndex table, uint rid)
Parameters
table
TableIndexThe table.
rid
uintThe row index.
Exceptions
- ArgumentOutOfRangeException
Occurs when
rid
is too large.
MetadataToken(uint)
Creates a new metadata token from a raw 32 bit integer.
public MetadataToken(uint value)
Parameters
value
uintThe raw metadata token.
Fields
Zero
Represents the zero metadata token, or the absence of a metadata token.
public static readonly MetadataToken Zero
Field Value
Properties
Rid
Gets the row index within the table specified by Table that the metadata token references.
public uint Rid { get; }
Property Value
Table
Gets the table that the metadata token references.
public TableIndex Table { get; }
Property Value
Methods
CompareTo(MetadataToken)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(MetadataToken other)
Parameters
other
MetadataTokenAn object to compare with this instance.
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes other
in the sort order.Zero This instance occurs in the same position in the sort order as other
.Greater than zero This instance follows other
in the sort order.
Equals(MetadataToken)
Determines whether the metadata token refers to the same member as another metadata token.
public bool Equals(MetadataToken other)
Parameters
other
MetadataTokenThe other metadata token.
Returns
- bool
true
if the token refers to the same member,false
otherwise.
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToInt32()
Converts the metadata token to a signed 32 bit integer.
public int ToInt32()
Returns
- int
The raw metadata token.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
ToUInt32()
Converts the metadata token to an unsigned 32 bit integer.
public uint ToUInt32()
Returns
- uint
The raw metadata token.
Operators
operator ==(MetadataToken, MetadataToken)
Determines whether two metadata tokens are considered equal. That is, both the table index and the row identifier match.
public static bool operator ==(MetadataToken a, MetadataToken b)
Parameters
a
MetadataTokenThe first metadata token.
b
MetadataTokenThe second metadata token.
Returns
- bool
true
if the tokens are considered equal,false
otherwise.
implicit operator MetadataToken(int)
Converts a 32-bit integer to a metadata token.
public static implicit operator MetadataToken(int token)
Parameters
token
intThe token to convert.
Returns
- MetadataToken
The metadata token.
implicit operator MetadataToken(uint)
Converts a 32-bit unsigned integer to a metadata token.
public static implicit operator MetadataToken(uint token)
Parameters
token
uintThe token to convert.
Returns
- MetadataToken
The metadata token.
operator !=(MetadataToken, MetadataToken)
Determines whether two metadata tokens are not considered equal. That is, either the table index or the row identifier (or both) does not match the other.
public static bool operator !=(MetadataToken a, MetadataToken b)
Parameters
a
MetadataTokenThe first metadata token.
b
MetadataTokenThe second metadata token.
Returns
- bool
true
if the tokens are not considered equal,false
otherwise.