ResolveType() private static method

private static ResolveType ( Module scope, string typeName ) : Type
scope Module
typeName string
return Type
示例#1
0
        internal CustomAttributeTypedArgument(RuntimeModule scope, CustomAttributeEncodedArgument encodedArg)
        {
            CustomAttributeEncoding encodedType = encodedArg.CustomAttributeType.EncodedType;

            switch (encodedType)
            {
            case CustomAttributeEncoding.Undefined:
                throw new ArgumentException("encodedArg");

            case CustomAttributeEncoding.Enum:
                RuntimeModule       scope1 = scope;
                CustomAttributeType customAttributeType = encodedArg.CustomAttributeType;
                string enumName = customAttributeType.EnumName;
                this.m_argumentType = (Type)CustomAttributeTypedArgument.ResolveType(scope1, enumName);
                long primitiveValue = encodedArg.PrimitiveValue;
                customAttributeType = encodedArg.CustomAttributeType;
                int num = (int)customAttributeType.EncodedEnumType;
                this.m_value = CustomAttributeTypedArgument.EncodedValueToRawValue(primitiveValue, (CustomAttributeEncoding)num);
                break;

            case CustomAttributeEncoding.String:
                this.m_argumentType = typeof(string);
                this.m_value        = (object)encodedArg.StringValue;
                break;

            case CustomAttributeEncoding.Type:
                this.m_argumentType = typeof(Type);
                this.m_value        = (object)null;
                if (encodedArg.StringValue == null)
                {
                    break;
                }
                this.m_value = (object)CustomAttributeTypedArgument.ResolveType(scope, encodedArg.StringValue);
                break;

            case CustomAttributeEncoding.Array:
                CustomAttributeEncoding encodedArrayType = encodedArg.CustomAttributeType.EncodedArrayType;
                this.m_argumentType = (encodedArrayType != CustomAttributeEncoding.Enum ? CustomAttributeTypedArgument.CustomAttributeEncodingToType(encodedArrayType) : (Type)CustomAttributeTypedArgument.ResolveType(scope, encodedArg.CustomAttributeType.EnumName)).MakeArrayType();
                if (encodedArg.ArrayValue == null)
                {
                    this.m_value = (object)null;
                    break;
                }
                CustomAttributeTypedArgument[] array = new CustomAttributeTypedArgument[encodedArg.ArrayValue.Length];
                for (int index = 0; index < array.Length; ++index)
                {
                    array[index] = new CustomAttributeTypedArgument(scope, encodedArg.ArrayValue[index]);
                }
                this.m_value = (object)Array.AsReadOnly <CustomAttributeTypedArgument>(array);
                break;

            default:
                this.m_argumentType = CustomAttributeTypedArgument.CustomAttributeEncodingToType(encodedType);
                this.m_value        = CustomAttributeTypedArgument.EncodedValueToRawValue(encodedArg.PrimitiveValue, encodedType);
                break;
            }
        }
        // Token: 0x0600443D RID: 17469 RVA: 0x000FA6D0 File Offset: 0x000F88D0
        internal CustomAttributeTypedArgument(RuntimeModule scope, CustomAttributeEncodedArgument encodedArg)
        {
            CustomAttributeEncoding customAttributeEncoding = encodedArg.CustomAttributeType.EncodedType;

            if (customAttributeEncoding == CustomAttributeEncoding.Undefined)
            {
                throw new ArgumentException("encodedArg");
            }
            if (customAttributeEncoding == CustomAttributeEncoding.Enum)
            {
                this.m_argumentType = CustomAttributeTypedArgument.ResolveType(scope, encodedArg.CustomAttributeType.EnumName);
                this.m_value        = CustomAttributeTypedArgument.EncodedValueToRawValue(encodedArg.PrimitiveValue, encodedArg.CustomAttributeType.EncodedEnumType);
                return;
            }
            if (customAttributeEncoding == CustomAttributeEncoding.String)
            {
                this.m_argumentType = typeof(string);
                this.m_value        = encodedArg.StringValue;
                return;
            }
            if (customAttributeEncoding == CustomAttributeEncoding.Type)
            {
                this.m_argumentType = typeof(Type);
                this.m_value        = null;
                if (encodedArg.StringValue != null)
                {
                    this.m_value = CustomAttributeTypedArgument.ResolveType(scope, encodedArg.StringValue);
                    return;
                }
            }
            else if (customAttributeEncoding == CustomAttributeEncoding.Array)
            {
                customAttributeEncoding = encodedArg.CustomAttributeType.EncodedArrayType;
                Type type;
                if (customAttributeEncoding == CustomAttributeEncoding.Enum)
                {
                    type = CustomAttributeTypedArgument.ResolveType(scope, encodedArg.CustomAttributeType.EnumName);
                }
                else
                {
                    type = CustomAttributeTypedArgument.CustomAttributeEncodingToType(customAttributeEncoding);
                }
                this.m_argumentType = type.MakeArrayType();
                if (encodedArg.ArrayValue == null)
                {
                    this.m_value = null;
                    return;
                }
                CustomAttributeTypedArgument[] array = new CustomAttributeTypedArgument[encodedArg.ArrayValue.Length];
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = new CustomAttributeTypedArgument(scope, encodedArg.ArrayValue[i]);
                }
                this.m_value = Array.AsReadOnly <CustomAttributeTypedArgument>(array);
                return;
            }
            else
            {
                this.m_argumentType = CustomAttributeTypedArgument.CustomAttributeEncodingToType(customAttributeEncoding);
                this.m_value        = CustomAttributeTypedArgument.EncodedValueToRawValue(encodedArg.PrimitiveValue, customAttributeEncoding);
            }
        }