Пример #1
0
        protected sealed override RuntimeType CreateDelayedRuntimeElementTypeIfAvailable()
        {
            ReflectionExecutionDomainCallbacks callbacks = RuntimeAugments.CallbacksIfAvailable;

            if (callbacks == null)
            {
                return(null);
            }

            RuntimeTypeHandle elementTypeHandle;

            if (!InternalIsMultiDimArray)
            {
                if (!callbacks.TryGetArrayTypeElementType(_runtimeTypeHandle, out elementTypeHandle))
                {
                    return(null);
                }
            }
            else
            {
                if (!callbacks.TryGetMultiDimArrayTypeElementType(_runtimeTypeHandle, Rank, out elementTypeHandle))
                {
                    return(null);
                }
            }

            return(ReflectionCoreNonPortable.GetRuntimeTypeForEEType(elementTypeHandle.EEType));
        }
Пример #2
0
        public sealed override Type MakeGenericType(params Type[] instantiation)
        {
            if (instantiation == null)
            {
                throw new ArgumentNullException("instantiation");
            }

            if (!(this.InternalIsGenericTypeDefinition))
            {
                throw new InvalidOperationException(SR.Format(SR.Arg_NotGenericTypeDefinition, this));
            }

            // We intentionally don't validate the number of arguments or their suitability to the generic type's constraints.
            // In a pay-for-play world, this can cause needless MissingMetadataExceptions. There is no harm in creating
            // the Type object for an inconsistent generic type - no EEType will ever match it so any attempt to "invoke" it
            // will throw an exception.
            RuntimeType[] genericTypeArguments = new RuntimeType[instantiation.Length];
            for (int i = 0; i < instantiation.Length; i++)
            {
                genericTypeArguments[i] = instantiation[i] as RuntimeType;
                if (genericTypeArguments[i] == null)
                {
                    if (instantiation[i] == null)
                    {
                        throw new ArgumentNullException();
                    }
                    else
                    {
                        throw new PlatformNotSupportedException(SR.PlatformNotSupported_MakeGenericType); // "PlatformNotSupported" because on desktop, passing in a foreign type is allowed and creates a RefEmit.TypeBuilder
                    }
                }
            }
            return(ReflectionCoreNonPortable.GetConstructedGenericType(this, genericTypeArguments));
        }
Пример #3
0
 public sealed override Type MakeArrayType()
 {
     // Do not implement this as a call to MakeArrayType(1) - they are not interchangable. MakeArrayType() returns a
     // vector type ("SZArray") while MakeArrayType(1) returns a multidim array of rank 1. These are distinct types
     // in the ECMA model and in CLR Reflection.
     return(ReflectionCoreNonPortable.GetArrayType(this));
 }
Пример #4
0
 public sealed override Type MakeArrayType(int rank)
 {
     if (rank <= 0)
     {
         throw new IndexOutOfRangeException();
     }
     return(ReflectionCoreNonPortable.GetMultiDimArrayType(this, rank));
 }
Пример #5
0
        public sealed override Type MakeArrayType()
        {
#if ENABLE_REFLECTION_TRACE
            if (ReflectionTrace.Enabled)
            {
                ReflectionTrace.Type_MakeArrayType(this);
            }
#endif

            // Do not implement this as a call to MakeArrayType(1) - they are not interchangable. MakeArrayType() returns a
            // vector type ("SZArray") while MakeArrayType(1) returns a multidim array of rank 1. These are distinct types
            // in the ECMA model and in CLR Reflection.
            return(ReflectionCoreNonPortable.GetArrayType(this));
        }
Пример #6
0
        public sealed override Type MakeArrayType(int rank)
        {
#if ENABLE_REFLECTION_TRACE
            if (ReflectionTrace.Enabled)
            {
                ReflectionTrace.Type_MakeArrayType(this);
            }
#endif

            if (rank <= 0)
            {
                throw new IndexOutOfRangeException();
            }
            return(ReflectionCoreNonPortable.GetMultiDimArrayType(this, rank));
        }
Пример #7
0
 public sealed override Type MakePointerType()
 {
     return(ReflectionCoreNonPortable.GetPointerType(this));
 }
Пример #8
0
 public sealed override Type MakeByRefType()
 {
     return(ReflectionCoreNonPortable.GetByRefType(this));
 }