本文整理汇总了C#中System.RuntimeTypeHandle类的典型用法代码示例。如果您正苦于以下问题:C# RuntimeTypeHandle类的具体用法?C# RuntimeTypeHandle怎么用?C# RuntimeTypeHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuntimeTypeHandle类属于System命名空间,在下文中一共展示了RuntimeTypeHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetMetadataForNamedType
public unsafe bool TryGetMetadataForNamedType(RuntimeTypeHandle runtimeTypeHandle, out MetadataReader metadataReader, out TypeDefinitionHandle typeDefHandle)
{
// Iterate over all modules, starting with the module that defines the EEType
foreach (IntPtr moduleHandle in ModuleList.Enumerate(RuntimeAugments.GetModuleFromTypeHandle(runtimeTypeHandle)))
{
MetadataTable mapTable = MetadataTable.CreateTypeMapTable(moduleHandle);
foreach (var ptrEntry in mapTable)
{
var pCurrentEntry = (TypeMapEntry*)ptrEntry;
RuntimeTypeHandle entryTypeHandle = RuntimeAugments.CreateRuntimeTypeHandle(pCurrentEntry->EEType);
Handle entryMetadataHandle = pCurrentEntry->TypeDefinitionHandle.AsHandle();
if (entryTypeHandle.Equals(runtimeTypeHandle) &&
entryMetadataHandle.HandleType == HandleType.TypeDefinition)
{
metadataReader = ModuleList.Instance.GetMetadataReaderForModule(moduleHandle);
typeDefHandle = entryMetadataHandle.ToTypeDefinitionHandle(metadataReader);
return true;
}
}
}
metadataReader = null;
typeDefHandle = default(TypeDefinitionHandle);
return false;
}
示例2: GetFieldFromHandle
public static FieldInfo GetFieldFromHandle(RuntimeFieldHandle handle, RuntimeTypeHandle declaringType)
{
if (handle.IsNullHandle())
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"));
return RuntimeType.GetFieldInfo(declaringType.GetRuntimeType(), handle.GetRuntimeFieldInfo());
}
示例3: GetNextArg
public TypedReference GetNextArg(RuntimeTypeHandle rth)
{
if (sigPtr != IntPtr.Zero)
{
// This is an ordinary ArgIterator capable of determining
// types from a signature. Just do a regular GetNextArg.
return GetNextArg();
}
else
{
// Prevent abuse of this API with a default ArgIterator (it
// doesn't require permission to create a zero-inited value
// type). Check that ArgPtr isn't zero or this API will allow a
// malicious caller to increment the pointer to an arbitrary
// location in memory and read the contents.
if (ArgPtr == IntPtr.Zero)
throw new ArgumentNullException();
TypedReference result = new TypedReference ();
// reference to TypedReference is banned, so have to pass result as pointer
unsafe
{
InternalGetNextArg(&result, rth.GetRuntimeType());
}
return result;
}
}
示例4: GetFunctionPointer
/// <summary>
/// Used by various parts of the runtime as a replacement for Delegate.Method
///
/// The Interop layer uses this to distinguish between different methods on a
/// single type, and to get the function pointer for delegates to static functions
///
/// The reflection apis use this api to figure out what MethodInfo is related
/// to a delegate.
///
/// </summary>
/// <param name="typeOfFirstParameterIfInstanceDelegate">
/// This value indicates which type an delegate's function pointer is associated with
/// This value is ONLY set for delegates where the function pointer points at an instance method
/// </param>
/// <param name="isOpenResolver">
/// This value indicates if the returned pointer is an open resolver structure.
/// </param>
/// <returns></returns>
unsafe internal IntPtr GetFunctionPointer(out RuntimeTypeHandle typeOfFirstParameterIfInstanceDelegate, out bool isOpenResolver)
{
typeOfFirstParameterIfInstanceDelegate = default(RuntimeTypeHandle);
isOpenResolver = false;
if (GetThunk(MulticastThunk) == m_functionPointer)
{
return IntPtr.Zero;
}
else if (m_extraFunctionPointerOrData != IntPtr.Zero)
{
if (GetThunk(OpenInstanceThunk) == m_functionPointer)
{
typeOfFirstParameterIfInstanceDelegate = ((OpenMethodResolver*)m_extraFunctionPointerOrData)->DeclaringType;
isOpenResolver = true;
}
return m_extraFunctionPointerOrData;
}
else
{
if (m_firstParameter != null)
typeOfFirstParameterIfInstanceDelegate = new RuntimeTypeHandle(m_firstParameter.EETypePtr);
// TODO! Implementation issue for generic invokes here ... we need another IntPtr for uniqueness.
return m_functionPointer;
}
}
示例5: NativeFormatRuntimeNamedTypeInfo
private NativeFormatRuntimeNamedTypeInfo(MetadataReader reader, TypeDefinitionHandle typeDefinitionHandle, RuntimeTypeHandle typeHandle) :
base(typeHandle)
{
_reader = reader;
_typeDefinitionHandle = typeDefinitionHandle;
_typeDefinition = _typeDefinitionHandle.GetTypeDefinition(reader);
}
示例6:
static bool 载入(RuntimeTypeHandle 窗口类型, ref 窗口 欲载入的窗口, IWin32Window 父窗口 = null, bool 是否采用对话框方式 = true)
{
欲载入的窗口 = (窗口)Activator.CreateInstance(Type.GetTypeFromHandle(窗口类型));
if (是否采用对话框方式) Application.Run(欲载入的窗口);
else 欲载入的窗口.Show(父窗口);
return true;
}
示例7: SerializeWithXsiType
protected override void SerializeWithXsiType(XmlWriterDelegator xmlWriter, object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, int declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
{
DataContract dataContract;
bool verifyKnownType = false;
bool isInterface = declaredType.IsInterface;
if (isInterface && CollectionDataContract.IsCollectionInterface(declaredType))
{
dataContract = this.GetDataContract(declaredTypeHandle, declaredType);
}
else if (declaredType.IsArray)
{
dataContract = this.GetDataContract(declaredTypeHandle, declaredType);
}
else
{
dataContract = this.GetDataContract(objectTypeHandle, objectType);
DataContract declaredContract = (declaredTypeID >= 0) ? this.GetDataContract(declaredTypeID, declaredTypeHandle) : this.GetDataContract(declaredTypeHandle, declaredType);
verifyKnownType = this.WriteTypeInfo(xmlWriter, dataContract, declaredContract);
this.HandleCollectionAssignedToObject(declaredType, ref dataContract, ref obj, ref verifyKnownType);
}
if (isInterface)
{
VerifyObjectCompatibilityWithInterface(dataContract, obj, declaredType);
}
base.SerializeAndVerifyType(dataContract, xmlWriter, obj, verifyKnownType, declaredType.TypeHandle, declaredType);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:XmlObjectSerializerWriteContextComplexJson.cs
示例8: TryGetGenericVirtualTargetForTypeAndSlot
public bool TryGetGenericVirtualTargetForTypeAndSlot(RuntimeTypeHandle targetHandle, ref RuntimeTypeHandle declaringType, RuntimeTypeHandle[] genericArguments, ref string methodName, ref RuntimeMethodSignature methodSignature, out IntPtr methodPointer, out IntPtr dictionaryPointer, out bool slotUpdated)
{
MethodNameAndSignature methodNameAndSignature = new MethodNameAndSignature(methodName, methodSignature);
#if REFLECTION_EXECUTION_TRACE
ReflectionExecutionLogger.WriteLine("GVM resolution starting for " + GetTypeNameDebug(declaringType) + "." + methodNameAndSignature.Name + "(...) on a target of type " + GetTypeNameDebug(targetHandle) + " ...");
#endif
if (RuntimeAugments.IsInterface(declaringType))
{
methodPointer = IntPtr.Zero;
dictionaryPointer = IntPtr.Zero;
slotUpdated = ResolveInterfaceGenericVirtualMethodSlot(targetHandle, ref declaringType, ref methodNameAndSignature);
methodName = methodNameAndSignature.Name;
methodSignature = methodNameAndSignature.Signature;
return slotUpdated;
}
else
{
slotUpdated = false;
return ResolveGenericVirtualMethodTarget(targetHandle, declaringType, genericArguments, methodNameAndSignature, out methodPointer, out dictionaryPointer);
}
}
示例9: GetFieldBinder
public GetFieldBinder(string name, RuntimeTypeHandle classContext, RuntimeTypeHandle returnType, AccessFlags access)
{
_name = name;
_returnType = Type.GetTypeFromHandle(returnType); // should correspond to AccessFlags
_classContext = Type.GetTypeFromHandle(classContext);
_access = access;
}
示例10: TestUseCase
public static void TestUseCase(Assert assert)
{
assert.Expect(7);
var t1 = new Type();
assert.Ok(t1 != null, "#565 t1");
var t2 = new ValueType();
assert.Ok(t2 != null, "#565 t2");
var t3 = new IntPtr();
assert.Ok(t3.GetType() == typeof(IntPtr) , "#565 t3");
var t4 = new UIntPtr();
assert.Ok(t4.GetType() == typeof(UIntPtr), "#565 t4");
var t5 = new ParamArrayAttribute();
assert.Ok(t5 != null, "#565 t5");
var t6 = new RuntimeTypeHandle();
assert.Ok(t6.GetType() == typeof(RuntimeTypeHandle), "#565 t6");
var t7 = new RuntimeFieldHandle();
assert.Ok(t7.GetType() == typeof(RuntimeFieldHandle), "#565 t7");
}
示例11: CallBinder
protected CallBinder(RuntimeTypeHandle returnType, int genericParams)
{
Debug.Assert(genericParams >= 0);
_returnType = Type.GetTypeFromHandle(returnType);
_genericParamsCount = genericParams;
}
示例12: GetTypeHandle
private static RuntimeTypeHandle GetTypeHandle(void* obj)
{
// TypeDefinition is located at the beginning of object (i.e. *obj )
RuntimeTypeHandle handle = new RuntimeTypeHandle();
((uint*)&handle)[0] = ((uint*)obj)[0];
return handle;
}
示例13: IsCanonicallyEquivalent
public bool IsCanonicallyEquivalent(RuntimeTypeHandle other)
{
if (_defType != null)
{
TypeDesc typeToFindAsCanon = _defType.ConvertToCanonForm(_canonKind);
TypeDesc otherTypeAsTypeDesc = _defType.Context.ResolveRuntimeTypeHandle(other);
TypeDesc otherTypeAsCanon = otherTypeAsTypeDesc.ConvertToCanonForm(_canonKind);
return typeToFindAsCanon == otherTypeAsCanon;
}
if (!_genericDefinition.IsNull())
{
if (RuntimeAugments.IsGenericType(other))
{
RuntimeTypeHandle otherGenericDefinition;
RuntimeTypeHandle[] otherGenericArgs;
otherGenericDefinition = RuntimeAugments.GetGenericInstantiation(other, out otherGenericArgs);
return _genericDefinition.Equals(otherGenericDefinition) && TypeLoaderEnvironment.Instance.CanInstantiationsShareCode(_genericArgs, otherGenericArgs, _canonKind);
}
else
return false;
}
else
return _typeToFind.Equals(other);
}
示例14: OpenMethodResolver
public unsafe OpenMethodResolver(RuntimeTypeHandle declaringTypeOfSlot, RuntimeMethodHandle gvmSlot, int handle)
{
_resolveType = GVMResolve;
_methodHandleOrSlotOrCodePointer = *(IntPtr*)&gvmSlot;
_declaringType = declaringTypeOfSlot;
_handle = handle;
}
示例15: FindMatchingInterfaceSlot
private bool FindMatchingInterfaceSlot(IntPtr moduleHandle, NativeReader nativeLayoutReader, ref NativeParser entryParser, ref ExternalReferencesTable extRefs, ref RuntimeTypeHandle declaringType, ref MethodNameAndSignature methodNameAndSignature, RuntimeTypeHandle openTargetTypeHandle, RuntimeTypeHandle[] targetTypeInstantiation, bool variantDispatch)
{
uint numTargetImplementations = entryParser.GetUnsigned();
for (uint j = 0; j < numTargetImplementations; j++)
{
uint nameAndSigToken = extRefs.GetRvaFromIndex(entryParser.GetUnsigned());
MethodNameAndSignature targetMethodNameAndSignature = GetMethodNameAndSignatureFromNativeReader(nativeLayoutReader, nameAndSigToken);
RuntimeTypeHandle targetTypeHandle = extRefs.GetRuntimeTypeHandleFromIndex(entryParser.GetUnsigned());
#if REFLECTION_EXECUTION_TRACE
ReflectionExecutionLogger.WriteLine(" Searching for GVM implementation on targe type = " + GetTypeNameDebug(targetTypeHandle));
#endif
uint numIfaceImpls = entryParser.GetUnsigned();
for (uint k = 0; k < numIfaceImpls; k++)
{
RuntimeTypeHandle implementingTypeHandle = extRefs.GetRuntimeTypeHandleFromIndex(entryParser.GetUnsigned());
uint numIfaceSigs = entryParser.GetUnsigned();
if (!openTargetTypeHandle.Equals(implementingTypeHandle))
{
// Skip over signatures data
for (uint l = 0; l < numIfaceSigs; l++)
entryParser.GetUnsigned();
continue;
}
for (uint l = 0; l < numIfaceSigs; l++)
{
RuntimeTypeHandle currentIfaceTypeHandle = default(RuntimeTypeHandle);
NativeParser ifaceSigParser = new NativeParser(nativeLayoutReader, extRefs.GetRvaFromIndex(entryParser.GetUnsigned()));
IntPtr currentIfaceSigPtr = ifaceSigParser.Reader.OffsetToAddress(ifaceSigParser.Offset);
if (TypeLoaderEnvironment.Instance.GetTypeFromSignatureAndContext(currentIfaceSigPtr, targetTypeInstantiation, null, out currentIfaceTypeHandle, out currentIfaceSigPtr))
{
Debug.Assert(!currentIfaceTypeHandle.IsNull());
if ((!variantDispatch && declaringType.Equals(currentIfaceTypeHandle)) ||
(variantDispatch && RuntimeAugments.IsAssignableFrom(declaringType, currentIfaceTypeHandle)))
{
#if REFLECTION_EXECUTION_TRACE
ReflectionExecutionLogger.WriteLine(" " + (declaringType.Equals(currentIfaceTypeHandle) ? "Exact" : "Variant-compatible") + " match found on this target type!");
#endif
// We found the GVM slot target for the input interface GVM call, so let's update the interface GVM slot and return success to the caller
declaringType = targetTypeHandle;
methodNameAndSignature = targetMethodNameAndSignature;
return true;
}
}
}
}
}
return false;
}