當前位置: 首頁>>代碼示例>>C#>>正文


C# RuntimeTypeHandle.GetTypeForRuntimeTypeHandle方法代碼示例

本文整理匯總了C#中System.RuntimeTypeHandle.GetTypeForRuntimeTypeHandle方法的典型用法代碼示例。如果您正苦於以下問題:C# RuntimeTypeHandle.GetTypeForRuntimeTypeHandle方法的具體用法?C# RuntimeTypeHandle.GetTypeForRuntimeTypeHandle怎麽用?C# RuntimeTypeHandle.GetTypeForRuntimeTypeHandle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.RuntimeTypeHandle的用法示例。


在下文中一共展示了RuntimeTypeHandle.GetTypeForRuntimeTypeHandle方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetMethodFromHandle

        //
        // This overload of GetMethodHandle can handle all method handles.
        //
        public sealed override MethodBase GetMethodFromHandle(RuntimeMethodHandle runtimeMethodHandle, RuntimeTypeHandle declaringTypeHandle)
        {
            ExecutionEnvironment executionEnvironment = ReflectionCoreExecution.ExecutionEnvironment;
            MethodHandle methodHandle;
            RuntimeTypeHandle[] genericMethodTypeArgumentHandles;
            if (!executionEnvironment.TryGetMethodFromHandleAndType(runtimeMethodHandle, declaringTypeHandle, out methodHandle, out genericMethodTypeArgumentHandles))
            {
                // This may be a method declared on a non-generic type: this api accepts that too so try the other table.
                RuntimeTypeHandle actualDeclaringTypeHandle;
                if (!executionEnvironment.TryGetMethodFromHandle(runtimeMethodHandle, out actualDeclaringTypeHandle, out methodHandle, out genericMethodTypeArgumentHandles))
                    throw new ArgumentException(SR.Argument_InvalidHandle);
                if (!actualDeclaringTypeHandle.Equals(declaringTypeHandle))
                    throw new ArgumentException(SR.Format(SR.Argument_ResolveMethodHandle,
                        declaringTypeHandle.GetTypeForRuntimeTypeHandle(),
                        actualDeclaringTypeHandle.GetTypeForRuntimeTypeHandle()));
            }

            MethodBase methodBase = ReflectionCoreExecution.ExecutionDomain.GetMethod(declaringTypeHandle, methodHandle, genericMethodTypeArgumentHandles);
            return methodBase;
        }
開發者ID:nattress,項目名稱:corert,代碼行數:23,代碼來源:ReflectionCoreCallbacksImplementation.cs

示例2: GetFieldInfo

 private FieldInfo GetFieldInfo(RuntimeTypeHandle declaringTypeHandle, FieldHandle fieldHandle)
 {
     RuntimeTypeInfo contextTypeInfo = declaringTypeHandle.GetTypeForRuntimeTypeHandle();
     RuntimeNamedTypeInfo definingTypeInfo = contextTypeInfo.AnchoringTypeDefinitionForDeclaredMembers;
     MetadataReader reader = definingTypeInfo.Reader;
     return RuntimeFieldInfo.GetRuntimeFieldInfo(fieldHandle, definingTypeInfo, contextTypeInfo);
 }
開發者ID:kyulee1,項目名稱:corert,代碼行數:7,代碼來源:ReflectionCoreCallbacksImplementation.cs

示例3: GetFieldFromHandle

        //
        // This overload of GetFieldHandle can handle all field handles.
        //
        public sealed override FieldInfo GetFieldFromHandle(RuntimeFieldHandle runtimeFieldHandle, RuntimeTypeHandle declaringTypeHandle)
        {
            ExecutionEnvironment executionEnvironment = ReflectionCoreExecution.ExecutionEnvironment;
            FieldHandle fieldHandle;
            if (!executionEnvironment.TryGetFieldFromHandleAndType(runtimeFieldHandle, declaringTypeHandle, out fieldHandle))
            {
                // This may be a field declared on a non-generic type: this api accepts that too so try the other table.
                RuntimeTypeHandle actualDeclaringTypeHandle;
                if (!executionEnvironment.TryGetFieldFromHandle(runtimeFieldHandle, out actualDeclaringTypeHandle, out fieldHandle))
                    throw new ArgumentException(SR.Argument_InvalidHandle);
                if (!actualDeclaringTypeHandle.Equals(declaringTypeHandle))
                    throw new ArgumentException(SR.Format(SR.Argument_ResolveFieldHandle,
                        declaringTypeHandle.GetTypeForRuntimeTypeHandle(),
                        actualDeclaringTypeHandle.GetTypeForRuntimeTypeHandle()));
            }

            FieldInfo fieldInfo = GetFieldInfo(declaringTypeHandle, fieldHandle);
            return fieldInfo;
        }
開發者ID:kyulee1,項目名稱:corert,代碼行數:22,代碼來源:ReflectionCoreCallbacksImplementation.cs

示例4: GetMethod

 //
 // Retrieves the MethodBase for a given method handle. Helper to implement Delegate.GetMethodInfo()
 //
 public MethodBase GetMethod(RuntimeTypeHandle declaringTypeHandle, MethodHandle methodHandle, RuntimeTypeHandle[] genericMethodTypeArgumentHandles)
 {
     RuntimeTypeInfo contextTypeInfo = declaringTypeHandle.GetTypeForRuntimeTypeHandle();
     RuntimeNamedTypeInfo definingTypeInfo = contextTypeInfo.AnchoringTypeDefinitionForDeclaredMembers;
     MetadataReader reader = definingTypeInfo.Reader;
     if (methodHandle.IsConstructor(reader))
     {
         return RuntimePlainConstructorInfo.GetRuntimePlainConstructorInfo(methodHandle, definingTypeInfo, contextTypeInfo);
     }
     else
     {
         RuntimeNamedMethodInfo runtimeNamedMethodInfo = RuntimeNamedMethodInfo.GetRuntimeNamedMethodInfo(methodHandle, definingTypeInfo, contextTypeInfo);
         if (!runtimeNamedMethodInfo.IsGenericMethod)
         {
             return runtimeNamedMethodInfo;
         }
         else
         {
             RuntimeTypeInfo[] genericTypeArguments = new RuntimeTypeInfo[genericMethodTypeArgumentHandles.Length];
             for (int i = 0; i < genericMethodTypeArgumentHandles.Length; i++)
             {
                 genericTypeArguments[i] = genericMethodTypeArgumentHandles[i].GetTypeForRuntimeTypeHandle();
             }
             return RuntimeConstructedGenericMethodInfo.GetRuntimeConstructedGenericMethodInfo(runtimeNamedMethodInfo, genericTypeArguments);
         }
     }
 }
開發者ID:kyulee1,項目名稱:corert,代碼行數:30,代碼來源:ExecutionDomain.cs

示例5: GetFieldInfo

        private FieldInfo GetFieldInfo(RuntimeTypeHandle declaringTypeHandle, FieldHandle fieldHandle)
        {
            RuntimeTypeInfo contextTypeInfo = declaringTypeHandle.GetTypeForRuntimeTypeHandle();
            NativeFormatRuntimeNamedTypeInfo definingTypeInfo = contextTypeInfo.AnchoringTypeDefinitionForDeclaredMembers.CastToNativeFormatRuntimeNamedTypeInfo();
            MetadataReader reader = definingTypeInfo.Reader;

            // RuntimeFieldHandles always yield FieldInfo's whose ReflectedType equals the DeclaringType.
            RuntimeTypeInfo reflectedType = contextTypeInfo;
            return NativeFormatRuntimeFieldInfo.GetRuntimeFieldInfo(fieldHandle, definingTypeInfo, contextTypeInfo, reflectedType);
        }
開發者ID:nattress,項目名稱:corert,代碼行數:10,代碼來源:ReflectionCoreCallbacksImplementation.cs

示例6: GetMethod

 //
 // Retrieves the MethodBase for a given method handle. Helper to implement Delegate.GetMethodInfo()
 //
 public MethodBase GetMethod(RuntimeTypeHandle declaringTypeHandle, MethodHandle methodHandle, RuntimeTypeHandle[] genericMethodTypeArgumentHandles)
 {
     RuntimeTypeInfo contextTypeInfo = declaringTypeHandle.GetTypeForRuntimeTypeHandle();
     NativeFormatRuntimeNamedTypeInfo definingTypeInfo = contextTypeInfo.AnchoringTypeDefinitionForDeclaredMembers.CastToNativeFormatRuntimeNamedTypeInfo();
     MetadataReader reader = definingTypeInfo.Reader;
     if (methodHandle.IsConstructor(reader))
     {
         return RuntimePlainConstructorInfo<NativeFormatMethodCommon>.GetRuntimePlainConstructorInfo(new NativeFormatMethodCommon(methodHandle, definingTypeInfo, contextTypeInfo));
     }
     else
     {
         // RuntimeMethodHandles always yield methods whose ReflectedType is the DeclaringType.
         RuntimeTypeInfo reflectedType = contextTypeInfo;
         RuntimeNamedMethodInfo<NativeFormatMethodCommon> runtimeNamedMethodInfo = RuntimeNamedMethodInfo<NativeFormatMethodCommon>.GetRuntimeNamedMethodInfo(new NativeFormatMethodCommon(methodHandle, definingTypeInfo, contextTypeInfo), reflectedType);
         if (!runtimeNamedMethodInfo.IsGenericMethod)
         {
             return runtimeNamedMethodInfo;
         }
         else
         {
             RuntimeTypeInfo[] genericTypeArguments = new RuntimeTypeInfo[genericMethodTypeArgumentHandles.Length];
             for (int i = 0; i < genericMethodTypeArgumentHandles.Length; i++)
             {
                 genericTypeArguments[i] = genericMethodTypeArgumentHandles[i].GetTypeForRuntimeTypeHandle();
             }
             return RuntimeConstructedGenericMethodInfo.GetRuntimeConstructedGenericMethodInfo(runtimeNamedMethodInfo, genericTypeArguments);
         }
     }
 }
開發者ID:nattress,項目名稱:corert,代碼行數:32,代碼來源:ExecutionDomain.cs


注:本文中的System.RuntimeTypeHandle.GetTypeForRuntimeTypeHandle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。