using System;
using System.Reflection;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
namespace System
{
/// Represents a runtime handle for a module.
/// 2
// Token: 0x02000689 RID: 1673
[ComVisible(true)]
public struct ModuleHandle
{
// Token: 0x06003F5F RID: 16223 RVA: 0x000D5FAC File Offset: 0x000D41AC
internal ModuleHandle(IntPtr v)
{
this.value = v;
}
// Token: 0x17000BC5 RID: 3013
// (get) Token: 0x06003F61 RID: 16225 RVA: 0x000D5FCC File Offset: 0x000D41CC
internal IntPtr Value
{
get
{
return this.value;
}
}
/// Gets the metadata stream version.
/// A 32-bit integer representing the metadata stream version. The high-order two bytes represent the major version number, and the low-order two bytes represent the minor version number.
// Token: 0x17000BC6 RID: 3014
// (get) Token: 0x06003F62 RID: 16226 RVA: 0x000D5FD4 File Offset: 0x000D41D4
public int MDStreamVersion
{
get
{
if (this.value == IntPtr.Zero)
{
throw new ArgumentNullException(string.Empty, "Invalid handle");
}
return Module.GetMDStreamVersion(this.value);
}
}
// Token: 0x06003F63 RID: 16227 RVA: 0x000D6014 File Offset: 0x000D4214
internal void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine)
{
if (this.value == IntPtr.Zero)
{
throw new ArgumentNullException(string.Empty, "Invalid handle");
}
Module.GetPEKind(this.value, out peKind, out machine);
}
/// Returns a runtime handle for the field identified by the specified metadata token.
/// A for the field identified by .
/// A metadata token that identifies a field in the module.
///
/// is not a valid token in the scope of the current module.-or- is not a token for a field in the scope of the current module.-or- identifies a field whose parent TypeSpec has a signature containing element type var or mvar.
/// The method is called on an empty field handle.
/// 1
// Token: 0x06003F64 RID: 16228 RVA: 0x000D6054 File Offset: 0x000D4254
public RuntimeFieldHandle ResolveFieldHandle(int fieldToken)
{
return this.ResolveFieldHandle(fieldToken, null, null);
}
/// Returns a runtime method handle for the method or constructor identified by the specified metadata token.
/// A for the method or constructor identified by .
/// A metadata token that identifies a method or constructor in the module.
///
/// is not a valid metadata token for a method in the current module.-or- is not a token for a method or constructor in the scope of the current module.-or- is a MethodSpec whose signature contains element type var or mvar.
/// The method is called on an empty method handle.
/// 1
// Token: 0x06003F65 RID: 16229 RVA: 0x000D6060 File Offset: 0x000D4260
public RuntimeMethodHandle ResolveMethodHandle(int methodToken)
{
return this.ResolveMethodHandle(methodToken, null, null);
}
/// Returns a runtime type handle for the type identified by the specified metadata token.
/// A for the type identified by .
/// A metadata token that identifies a type in the module.
///
/// is not a valid metadata token for a type in the current module.-or- is not a token for a type in the scope of the current module.-or- is a TypeSpec whose signature contains element type var or mvar.
/// The method is called on an empty type handle.
/// 1
// Token: 0x06003F66 RID: 16230 RVA: 0x000D606C File Offset: 0x000D426C
public RuntimeTypeHandle ResolveTypeHandle(int typeToken)
{
return this.ResolveTypeHandle(typeToken, null, null);
}
// Token: 0x06003F67 RID: 16231 RVA: 0x000D6078 File Offset: 0x000D4278
private IntPtr[] ptrs_from_handles(RuntimeTypeHandle[] handles)
{
if (handles == null)
{
return null;
}
IntPtr[] array = new IntPtr[handles.Length];
for (int i = 0; i < handles.Length; i++)
{
array[i] = handles[i].Value;
}
return array;
}
/// Returns a runtime type handle for the type identified by the specified metadata token, specifying the generic type arguments of the type and method where the token is in scope.
/// A for the type identified by .
/// A metadata token that identifies a type in the module.
/// An array of structures representing the generic type arguments of the type where the token is in scope, or null if that type is not generic.
/// An array of structures objects representing the generic type arguments of the method where the token is in scope, or null if that method is not generic.
///
/// is not a valid metadata token for a type in the current module.-or- is not a token for a type in the scope of the current module.-or- is a TypeSpec whose signature contains element type var or mvar.
/// The method is called on an empty type handle.
///
/// is not a valid token.
// Token: 0x06003F68 RID: 16232 RVA: 0x000D60C4 File Offset: 0x000D42C4
public RuntimeTypeHandle ResolveTypeHandle(int typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
{
if (this.value == IntPtr.Zero)
{
throw new ArgumentNullException(string.Empty, "Invalid handle");
}
ResolveTokenError resolveTokenError;
IntPtr intPtr = Module.ResolveTypeToken(this.value, typeToken, this.ptrs_from_handles(typeInstantiationContext), this.ptrs_from_handles(methodInstantiationContext), out resolveTokenError);
if (intPtr == IntPtr.Zero)
{
throw new TypeLoadException(string.Format("Could not load type '0x{0:x}' from assembly '0x{1:x}'", typeToken, this.value.ToInt64()));
}
return new RuntimeTypeHandle(intPtr);
}
/// Returns a runtime method handle for the method or constructor identified by the specified metadata token, specifying the generic type arguments of the type and method where the token is in scope.
/// A for the method or constructor identified by .
/// A metadata token that identifies a method or constructor in the module.
/// An array of structures representing the generic type arguments of the type where the token is in scope, or null if that type is not generic.
/// An array of structures representing the generic type arguments of the method where the token is in scope, or null if that method is not generic.
///
/// is not a valid metadata token for a method in the current module.-or- is not a token for a method or constructor in the scope of the current module.-or- is a MethodSpec whose signature contains element type var or mvar.
/// The method is called on an empty method handle.
///
/// is not a valid token.
// Token: 0x06003F69 RID: 16233 RVA: 0x000D6150 File Offset: 0x000D4350
public RuntimeMethodHandle ResolveMethodHandle(int methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
{
if (this.value == IntPtr.Zero)
{
throw new ArgumentNullException(string.Empty, "Invalid handle");
}
ResolveTokenError resolveTokenError;
IntPtr intPtr = Module.ResolveMethodToken(this.value, methodToken, this.ptrs_from_handles(typeInstantiationContext), this.ptrs_from_handles(methodInstantiationContext), out resolveTokenError);
if (intPtr == IntPtr.Zero)
{
throw new Exception(string.Format("Could not load method '0x{0:x}' from assembly '0x{1:x}'", methodToken, this.value.ToInt64()));
}
return new RuntimeMethodHandle(intPtr);
}
/// Returns a runtime field handle for the field identified by the specified metadata token, specifying the generic type arguments of the type and method where the token is in scope.
/// A for the field identified by .
/// A metadata token that identifies a field in the module.
/// An array of structures representing the generic type arguments of the type where the token is in scope, or null if that type is not generic.
/// An array of structures representing the generic type arguments of the method where the token is in scope, or null if that method is not generic.
///
/// is not a valid token in the scope of the current module.-or- is not a token for a field in the scope of the current module.-or- identifies a field whose parent TypeSpec has a signature containing element type var or mvar.
/// The method is called on an empty field handle.
///
/// is not a valid token.
// Token: 0x06003F6A RID: 16234 RVA: 0x000D61DC File Offset: 0x000D43DC
public RuntimeFieldHandle ResolveFieldHandle(int fieldToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
{
if (this.value == IntPtr.Zero)
{
throw new ArgumentNullException(string.Empty, "Invalid handle");
}
ResolveTokenError resolveTokenError;
IntPtr intPtr = Module.ResolveFieldToken(this.value, fieldToken, this.ptrs_from_handles(typeInstantiationContext), this.ptrs_from_handles(methodInstantiationContext), out resolveTokenError);
if (intPtr == IntPtr.Zero)
{
throw new Exception(string.Format("Could not load field '0x{0:x}' from assembly '0x{1:x}'", fieldToken, this.value.ToInt64()));
}
return new RuntimeFieldHandle(intPtr);
}
/// Returns a runtime handle for the field identified by the specified metadata token.
/// A for the field identified by .
/// A metadata token that identifies a field in the module.
/// 2
// Token: 0x06003F6B RID: 16235 RVA: 0x000D6268 File Offset: 0x000D4468
public RuntimeFieldHandle GetRuntimeFieldHandleFromMetadataToken(int fieldToken)
{
return this.ResolveFieldHandle(fieldToken);
}
/// Returns a runtime method handle for the method or constructor identified by the specified metadata token.
/// A for the method or constructor identified by .
/// A metadata token that identifies a method or constructor in the module.
/// 2
// Token: 0x06003F6C RID: 16236 RVA: 0x000D6274 File Offset: 0x000D4474
public RuntimeMethodHandle GetRuntimeMethodHandleFromMetadataToken(int methodToken)
{
return this.ResolveMethodHandle(methodToken);
}
/// Returns a runtime type handle for the type identified by the specified metadata token.
/// A for the type identified by .
/// A metadata token that identifies a type in the module.
/// 2
// Token: 0x06003F6D RID: 16237 RVA: 0x000D6280 File Offset: 0x000D4480
public RuntimeTypeHandle GetRuntimeTypeHandleFromMetadataToken(int typeToken)
{
return this.ResolveTypeHandle(typeToken);
}
/// Returns a value indicating whether the specified object is a structure, and equal to the current .
/// true if is a structure, and is equal to the current structure; otherwise, false.
/// The object to be compared with the current structure.
/// 2
// Token: 0x06003F6E RID: 16238 RVA: 0x000D628C File Offset: 0x000D448C
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public override bool Equals(object obj)
{
return obj != null && base.GetType() == obj.GetType() && this.value == ((ModuleHandle)obj).Value;
}
/// Returns a value indicating whether the specified structure is equal to the current .
/// true if is equal to the current structure; otherwise false.
/// The structure to be compared with the current .
/// 2
// Token: 0x06003F6F RID: 16239 RVA: 0x000D62D8 File Offset: 0x000D44D8
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public bool Equals(ModuleHandle handle)
{
return this.value == handle.Value;
}
/// 2
// Token: 0x06003F70 RID: 16240 RVA: 0x000D62EC File Offset: 0x000D44EC
public override int GetHashCode()
{
return this.value.GetHashCode();
}
/// Tests whether two structures are equal.
/// true if the structures are equal; otherwise, false.
/// The structure to the left of the equality operator.
/// The structure to the right of the equality operator.
/// 3
// Token: 0x06003F71 RID: 16241 RVA: 0x000D62FC File Offset: 0x000D44FC
public static bool operator ==(ModuleHandle left, ModuleHandle right)
{
return object.Equals(left, right);
}
/// Tests whether two structures are unequal.
/// true if the structures are unequal; otherwise, false.
/// The structure to the left of the inequality operator.
/// The structure to the right of the inequality operator.
/// 3
// Token: 0x06003F72 RID: 16242 RVA: 0x000D6310 File Offset: 0x000D4510
public static bool operator !=(ModuleHandle left, ModuleHandle right)
{
return !object.Equals(left, right);
}
// Token: 0x04001937 RID: 6455
private IntPtr value;
/// Represents an empty module handle.
/// 1
// Token: 0x04001938 RID: 6456
public static readonly ModuleHandle EmptyHandle = new ModuleHandle(IntPtr.Zero);
}
}