Beispiel #1
0
 private static RuntimeTypeInfo CreateRuntimeTypeInfo(RuntimeType runtimeType)
 {
     if (runtimeType.HasElementType)
     {
         if (runtimeType.IsArray)
         {
             return(RuntimeArrayTypeInfo.GetRuntimeArrayTypeInfo(runtimeType));
         }
         else
         {
             return(RuntimeHasElementTypeInfo.GetRuntimeHasElementypeInfo(runtimeType));
         }
     }
     else if (runtimeType.IsConstructedGenericType)
     {
         RuntimeTypeHandle typeHandle;
         if (runtimeType.InternalTryGetTypeHandle(out typeHandle) && ReflectionCoreExecution.ExecutionEnvironment.IsReflectionBlocked(typeHandle))
         {
             return(RuntimeBlockedTypeInfo.GetRuntimeBlockedTypeInfo(runtimeType));
         }
         return(RuntimeConstructedGenericTypeInfo.GetRuntimeConstructedGenericTypeInfo(runtimeType));
     }
     else
     {
         RuntimeInspectionOnlyNamedType inspectionOnlyNamedType = runtimeType as RuntimeInspectionOnlyNamedType;
         if (inspectionOnlyNamedType != null)
         {
             return(inspectionOnlyNamedType.GetInspectionOnlyNamedRuntimeTypeInfo());
         }
         else
         {
             RuntimeGenericParameterType genericParameterType = runtimeType as RuntimeGenericParameterType;
             if (genericParameterType != null)
             {
                 return(RuntimeGenericParameterTypeInfo.GetRuntimeGenericParameterTypeInfo(genericParameterType));
             }
             else
             {
                 MetadataReader       reader;
                 TypeDefinitionHandle typeDefHandle;
                 if (ReflectionCoreExecution.ExecutionEnvironment.TryGetMetadataForNamedType(runtimeType.TypeHandle, out reader, out typeDefHandle))
                 {
                     return(RuntimeNamedTypeInfo.GetRuntimeNamedTypeInfo(reader, typeDefHandle));
                 }
                 if (ReflectionCoreExecution.ExecutionEnvironment.IsReflectionBlocked(runtimeType.TypeHandle))
                 {
                     return(RuntimeBlockedTypeInfo.GetRuntimeBlockedTypeInfo(runtimeType));
                 }
                 else
                 {
                     return(RuntimeNoMetadataNamedTypeInfo.GetRuntimeNoMetadataNamedTypeInfo(runtimeType));
                 }
             }
         }
     }
 }
Beispiel #2
0
            protected sealed override RuntimeType Factory(QTypeDefinition qTypeDefinition)
            {
                RuntimeTypeHandle runtimeTypeHandle;

                if (ReflectionCoreExecution.ExecutionEnvironment.TryGetNamedTypeForMetadata(qTypeDefinition.Reader, qTypeDefinition.Handle, out runtimeTypeHandle))
                {
                    return(ReflectionCoreNonPortable.GetTypeForRuntimeTypeHandle(runtimeTypeHandle));
                }
                else
                {
                    return(RuntimeInspectionOnlyNamedType.GetRuntimeInspectionOnlyNamedType(qTypeDefinition.Reader, qTypeDefinition.Handle));
                }
            }