예제 #1
0
        public bool Equals(NativeFormatRuntimeNamedTypeInfo other)
        {
            // RuntimeTypeInfo.Equals(object) is the one that encapsulates our unification strategy so defer to him.
            object otherAsObject = other;

            return(base.Equals(otherAsObject));
        }
 //
 // fieldHandle    - the "tkFieldDef" that identifies the field.
 // definingType   - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created fieldHandle.)
 // contextType    - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you
 //                  get your raw information from "definingType", you report "contextType" as your DeclaringType property.
 //
 //  For example:
 //
 //       typeof(Foo<>).GetTypeInfo().DeclaredMembers
 //
 //           The definingType and contextType are both Foo<>
 //
 //       typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers
 //
 //          The definingType is "Foo<,>"
 //          The contextType is "Foo<int,String>"
 //
 //  We don't report any DeclaredMembers for arrays or generic parameters so those don't apply.
 //
 private NativeFormatRuntimeFieldInfo(FieldHandle fieldHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) :
     base(contextTypeInfo, reflectedType)
 {
     _fieldHandle = fieldHandle;
     _definingTypeInfo = definingTypeInfo;
     _reader = definingTypeInfo.Reader;
     _field = fieldHandle.GetField(_reader);
 }
 //
 // propertyHandle - the "tkPropertyDef" that identifies the property.
 // definingType   - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created propertyHandle.)
 // contextType    - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you
 //                  get your raw information from "definingType", you report "contextType" as your DeclaringType property.
 //
 //  For example:
 //
 //       typeof(Foo<>).GetTypeInfo().DeclaredMembers
 //
 //           The definingType and contextType are both Foo<>
 //
 //       typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers
 //
 //          The definingType is "Foo<,>"
 //          The contextType is "Foo<int,String>"
 //
 //  We don't report any DeclaredMembers for arrays or generic parameters so those don't apply.
 //
 private NativeFormatRuntimePropertyInfo(PropertyHandle propertyHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) :
     base(contextTypeInfo, reflectedType)
 {
     _propertyHandle = propertyHandle;
     _definingTypeInfo = definingTypeInfo;
     _reader = definingTypeInfo.Reader;
     _property = propertyHandle.GetProperty(_reader);
 }
 //
 // eventHandle    - the "tkEventDef" that identifies the event.
 // definingType   - the "tkTypeDef" that defined the field (this is where you get the metadata reader that created eventHandle.)
 // contextType    - the type that supplies the type context (i.e. substitutions for generic parameters.) Though you
 //                  get your raw information from "definingType", you report "contextType" as your DeclaringType property.
 //
 //  For example:
 //
 //       typeof(Foo<>).GetTypeInfo().DeclaredMembers
 //
 //           The definingType and contextType are both Foo<>
 //
 //       typeof(Foo<int,String>).GetTypeInfo().DeclaredMembers
 //
 //          The definingType is "Foo<,>"
 //          The contextType is "Foo<int,String>"
 //
 //  We don't report any DeclaredMembers for arrays or generic parameters so those don't apply.
 //
 private NativeFormatRuntimeEventInfo(EventHandle eventHandle, NativeFormatRuntimeNamedTypeInfo definingTypeInfo, RuntimeTypeInfo contextTypeInfo, RuntimeTypeInfo reflectedType) :
     base(contextTypeInfo, reflectedType)
 {
     _eventHandle = eventHandle;
     _definingTypeInfo = definingTypeInfo;
     _reader = definingTypeInfo.Reader;
     _event = eventHandle.GetEvent(_reader);
 }
예제 #5
0
        internal static NativeFormatRuntimeNamedTypeInfo GetRuntimeNamedTypeInfo(MetadataReader metadataReader, TypeDefinitionHandle typeDefHandle, RuntimeTypeHandle precomputedTypeHandle)
        {
            RuntimeTypeHandle typeHandle = precomputedTypeHandle;

            if (typeHandle.IsNull())
            {
                if (!ReflectionCoreExecution.ExecutionEnvironment.TryGetNamedTypeForMetadata(new QTypeDefinition(metadataReader, typeDefHandle), out typeHandle))
                {
                    typeHandle = default(RuntimeTypeHandle);
                }
            }
            UnificationKey key = new UnificationKey(metadataReader, typeDefHandle, typeHandle);

            NativeFormatRuntimeNamedTypeInfo type = NamedTypeTable.Table.GetOrAdd(key);

            type.EstablishDebugName();
            return(type);
        }
예제 #6
0
        //
        // For app-compat reasons, we need to make sure that only TypeInfo instance exists for a given semantic type. If you change this, you must change the way
        // RuntimeTypeInfo.Equals() is implemented.
        //
        internal static NativeFormatRuntimeGenericParameterTypeInfoForTypes GetRuntimeGenericParameterTypeInfoForTypes(NativeFormatRuntimeNamedTypeInfo typeOwner, GenericParameterHandle genericParameterHandle)
        {
            UnificationKey key = new UnificationKey(typeOwner.Reader, typeOwner.TypeDefinitionHandle, genericParameterHandle);
            NativeFormatRuntimeGenericParameterTypeInfoForTypes type = GenericParameterTypeForTypesTable.Table.GetOrAdd(key);

            type.EstablishDebugName();
            return(type);
        }
 public bool Equals(NativeFormatRuntimeNamedTypeInfo other)
 {
     // RuntimeTypeInfo.Equals(object) is the one that encapsulates our unification strategy so defer to him.
     object otherAsObject = other;
     return base.Equals(otherAsObject);
 }