System.Reflection.CustomAttributeTypedArgument.CustomAttributeEncodingToType C# (CSharp) Method

CustomAttributeEncodingToType() private static method

private static CustomAttributeEncodingToType ( CustomAttributeEncoding encodedType ) : Type
encodedType CustomAttributeEncoding
return Type
        private static Type CustomAttributeEncodingToType(CustomAttributeEncoding encodedType)
        {
            switch (encodedType)
            {
                case (CustomAttributeEncoding.Enum):
                    return typeof(Enum);

                case (CustomAttributeEncoding.Int32):
                    return typeof(int);

                case (CustomAttributeEncoding.String):
                    return typeof(string);

                case (CustomAttributeEncoding.Type):
                    return typeof(Type);

                case (CustomAttributeEncoding.Array):
                    return typeof(Array);

                case (CustomAttributeEncoding.Char):
                    return typeof(char);

                case (CustomAttributeEncoding.Boolean):
                    return typeof(bool);

                case (CustomAttributeEncoding.SByte):
                    return typeof(sbyte);

                case (CustomAttributeEncoding.Byte):
                    return typeof(byte);

                case (CustomAttributeEncoding.Int16):
                    return typeof(short);

                case (CustomAttributeEncoding.UInt16):
                    return typeof(ushort);

                case (CustomAttributeEncoding.UInt32):
                    return typeof(uint);

                case (CustomAttributeEncoding.Int64):
                    return typeof(long);

                case (CustomAttributeEncoding.UInt64):
                    return typeof(ulong);

                case (CustomAttributeEncoding.Float):
                    return typeof(float);

                case (CustomAttributeEncoding.Double):
                    return typeof(double);

                case (CustomAttributeEncoding.Object):
                    return typeof(object);

                default :
                    throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)encodedType), "encodedType");
            }
        }
        private static object EncodedValueToRawValue(long val, CustomAttributeEncoding encodedType)

Usage Example

Esempio n. 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;
            }
        }
All Usage Examples Of System.Reflection.CustomAttributeTypedArgument::CustomAttributeEncodingToType