Example #1
0
        private static CustomAttributeType InitCustomAttributeType(RuntimeType parameterType)
        {
            int num1 = (int)CustomAttributeData.TypeToCustomAttributeEncoding(parameterType);
            CustomAttributeEncoding attributeEncoding1 = CustomAttributeEncoding.Undefined;
            CustomAttributeEncoding attributeEncoding2 = CustomAttributeEncoding.Undefined;
            string str  = (string)null;
            int    num2 = 29;

            if (num1 == num2)
            {
                parameterType      = (RuntimeType)parameterType.GetElementType();
                attributeEncoding1 = CustomAttributeData.TypeToCustomAttributeEncoding(parameterType);
            }
            int num3 = 85;

            if (num1 == num3 || attributeEncoding1 == CustomAttributeEncoding.Enum)
            {
                attributeEncoding2 = CustomAttributeData.TypeToCustomAttributeEncoding((RuntimeType)Enum.GetUnderlyingType((Type)parameterType));
                str = parameterType.AssemblyQualifiedName;
            }
            int    num4     = (int)attributeEncoding1;
            int    num5     = (int)attributeEncoding2;
            string enumName = str;

            return(new CustomAttributeType((CustomAttributeEncoding)num1, (CustomAttributeEncoding)num4, (CustomAttributeEncoding)num5, enumName));
        }
        private static CustomAttributeType InitCustomAttributeType(Type parameterType, Module scope)
        {
            CustomAttributeEncoding encodedType     = TypeToCustomAttributeEncoding(parameterType);
            CustomAttributeEncoding undefined       = CustomAttributeEncoding.Undefined;
            CustomAttributeEncoding encodedEnumType = CustomAttributeEncoding.Undefined;
            string enumName = null;

            if (encodedType == CustomAttributeEncoding.Array)
            {
                parameterType = parameterType.GetElementType();
                undefined     = TypeToCustomAttributeEncoding(parameterType);
            }
            if ((encodedType == CustomAttributeEncoding.Enum) || (undefined == CustomAttributeEncoding.Enum))
            {
                encodedEnumType = TypeToCustomAttributeEncoding(Enum.GetUnderlyingType(parameterType));
                if (parameterType.Module == scope)
                {
                    enumName = parameterType.FullName;
                }
                else
                {
                    enumName = parameterType.AssemblyQualifiedName;
                }
            }
            return(new CustomAttributeType(encodedType, undefined, encodedEnumType, enumName));
        }
Example #3
0
        private static Type CustomAttributeEncodingToType(CustomAttributeEncoding encodedType)
        {
            switch (encodedType)
            {
            case CustomAttributeEncoding.Type:
                return(typeof(Type));

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

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

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

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

            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.Int32:
                return(typeof(int));

            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.String:
                return(typeof(string));

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

            default:
                throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (object)encodedType), "encodedType");
            }
        }
Example #4
0
 // Token: 0x06004450 RID: 17488 RVA: 0x000FAB5D File Offset: 0x000F8D5D
 public CustomAttributeType(CustomAttributeEncoding encodedType, CustomAttributeEncoding encodedArrayType, CustomAttributeEncoding encodedEnumType, string enumName)
 {
     this.m_encodedType      = encodedType;
     this.m_encodedArrayType = encodedArrayType;
     this.m_encodedEnumType  = encodedEnumType;
     this.m_enumName         = enumName;
     this.m_padding          = this.m_encodedType;
 }
 public CustomAttributeType(CustomAttributeEncoding encodedType, CustomAttributeEncoding encodedArrayType, CustomAttributeEncoding encodedEnumType, string enumName)
 {
     this.m_encodedType = encodedType;
     this.m_encodedArrayType = encodedArrayType;
     this.m_encodedEnumType = encodedEnumType;
     this.m_enumName = enumName;
     this.m_padding = this.m_encodedType;
 }
        private static Type CustomAttributeEncodingToType(CustomAttributeEncoding encodedType)
        {
            switch (encodedType)
            {
                case CustomAttributeEncoding.Boolean:
                    return typeof(bool);

                case CustomAttributeEncoding.Char:
                    return typeof(char);

                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.Int32:
                    return typeof(int);

                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.String:
                    return typeof(string);

                case CustomAttributeEncoding.Array:
                    return typeof(Array);

                case CustomAttributeEncoding.Type:
                    return typeof(Type);

                case CustomAttributeEncoding.Object:
                    return typeof(object);

                case CustomAttributeEncoding.Enum:
                    return typeof(Enum);
            }
            throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", new object[] { (int) encodedType }), "encodedType");
        }
Example #7
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;
            }
        }
 public CustomAttributeNamedParameter(string argumentName, CustomAttributeEncoding fieldOrProperty, CustomAttributeType type)
 {
     if (argumentName == null)
     {
         throw new ArgumentNullException("argumentName");
     }
     this.m_argumentName    = argumentName;
     this.m_fieldOrProperty = fieldOrProperty;
     this.m_padding         = fieldOrProperty;
     this.m_type            = type;
     this.m_encodedArgument = new CustomAttributeEncodedArgument();
 }
 public CustomAttributeNamedParameter(string argumentName, CustomAttributeEncoding fieldOrProperty, CustomAttributeType type)
 {
     if (argumentName == null)
     {
         throw new ArgumentNullException("argumentName");
     }
     this.m_argumentName = argumentName;
     this.m_fieldOrProperty = fieldOrProperty;
     this.m_padding = fieldOrProperty;
     this.m_type = type;
     this.m_encodedArgument = new CustomAttributeEncodedArgument();
 }
        private unsafe static object EncodedValueToRawValue(long val, CustomAttributeEncoding encodedType)
        {
            switch (encodedType)
            {
            case CustomAttributeEncoding.Boolean:
                return((byte)val > 0);

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

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

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

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

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

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

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

            case CustomAttributeEncoding.Int64:
                return(val);

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

            case CustomAttributeEncoding.Float:
                return(*(float *)(&val));

            case CustomAttributeEncoding.Double:
                return(*(double *)(&val));

            default:
                throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", new object[]
                {
                    (int)val
                }), "val");
            }
        }
Example #11
0
        // Token: 0x06004416 RID: 17430 RVA: 0x000F97C4 File Offset: 0x000F79C4
        private static CustomAttributeType InitCustomAttributeType(RuntimeType parameterType)
        {
            CustomAttributeEncoding customAttributeEncoding  = CustomAttributeData.TypeToCustomAttributeEncoding(parameterType);
            CustomAttributeEncoding customAttributeEncoding2 = CustomAttributeEncoding.Undefined;
            CustomAttributeEncoding encodedEnumType          = CustomAttributeEncoding.Undefined;
            string enumName = null;

            if (customAttributeEncoding == CustomAttributeEncoding.Array)
            {
                parameterType            = (RuntimeType)parameterType.GetElementType();
                customAttributeEncoding2 = CustomAttributeData.TypeToCustomAttributeEncoding(parameterType);
            }
            if (customAttributeEncoding == CustomAttributeEncoding.Enum || customAttributeEncoding2 == CustomAttributeEncoding.Enum)
            {
                encodedEnumType = CustomAttributeData.TypeToCustomAttributeEncoding((RuntimeType)Enum.GetUnderlyingType(parameterType));
                enumName        = parameterType.AssemblyQualifiedName;
            }
            return(new CustomAttributeType(customAttributeEncoding, customAttributeEncoding2, encodedEnumType, enumName));
        }
        private static unsafe object EncodedValueToRawValue(long val, CustomAttributeEncoding encodedType)
        {
            switch (encodedType)
            {
                case CustomAttributeEncoding.Boolean:
                    return (((byte) val) != 0);

                case CustomAttributeEncoding.Char:
                    return (char) ((ushort) val);

                case CustomAttributeEncoding.SByte:
                    return (sbyte) val;

                case CustomAttributeEncoding.Byte:
                    return (byte) val;

                case CustomAttributeEncoding.Int16:
                    return (short) val;

                case CustomAttributeEncoding.UInt16:
                    return (ushort) val;

                case CustomAttributeEncoding.Int32:
                    return (int) val;

                case CustomAttributeEncoding.UInt32:
                    return (uint) val;

                case CustomAttributeEncoding.Int64:
                    return val;

                case CustomAttributeEncoding.UInt64:
                    return (ulong) val;

                case CustomAttributeEncoding.Float:
                    return *(((float*) &val));

                case CustomAttributeEncoding.Double:
                    return *(((double*) &val));
            }
            throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", new object[] { (int) val }), "val");
        }
Example #13
0
        internal CustomAttributeTypedArgument(Module scope, CustomAttributeEncodedArgument encodedArg)
        {
            CustomAttributeEncoding encodedType = encodedArg.CustomAttributeType.EncodedType;

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

            case CustomAttributeEncoding.Enum:
                this.m_argumentType = ResolveType(scope, encodedArg.CustomAttributeType.EnumName);
                this.m_value        = EncodedValueToRawValue(encodedArg.PrimitiveValue, encodedArg.CustomAttributeType.EncodedEnumType);
                return;

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

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

            case CustomAttributeEncoding.Array:
            {
                Type type;
                encodedType = encodedArg.CustomAttributeType.EncodedArrayType;
                if (encodedType == CustomAttributeEncoding.Enum)
                {
                    type = ResolveType(scope, encodedArg.CustomAttributeType.EnumName);
                }
                else
                {
                    type = CustomAttributeEncodingToType(encodedType);
                }
                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;
            }

            default:
                this.m_argumentType = CustomAttributeEncodingToType(encodedType);
                this.m_value        = EncodedValueToRawValue(encodedArg.PrimitiveValue, encodedType);
                break;
            }
        }
Example #14
0
        private static object EncodedValueToRawValue(long val, CustomAttributeEncoding encodedType)
        {
            switch (encodedType)
            {
                case CustomAttributeEncoding.Boolean:
                    return (byte)val != 0;

                case CustomAttributeEncoding.Char:
                    return (char)val;

                case CustomAttributeEncoding.Byte:
                    return (byte)val;

                case CustomAttributeEncoding.SByte:
                    return (sbyte)val;

                case CustomAttributeEncoding.Int16:
                    return (short)val;

                case CustomAttributeEncoding.UInt16:
                    return (ushort)val;

                case CustomAttributeEncoding.Int32:
                    return (int)val;

                case CustomAttributeEncoding.UInt32:
                    return (uint)val;

                case CustomAttributeEncoding.Int64:
                    return (long)val;

                case CustomAttributeEncoding.UInt64:
                    return (ulong)val;

                case CustomAttributeEncoding.Float:
                    unsafe { return *(float*)&val; }

                case CustomAttributeEncoding.Double:
                    unsafe { return *(double*)&val; }

                default:
                    throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)val), "val");
            }
        }
Example #15
0
        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), nameof(encodedType));
            }
        }
Example #16
0
        public CustomAttributeNamedParameter(string argumentName, CustomAttributeEncoding fieldOrProperty, CustomAttributeType type)
        {
            if (argumentName == null)
                throw new ArgumentNullException(nameof(argumentName));
            Contract.EndContractBlock();

            m_argumentName = argumentName;
            m_fieldOrProperty = fieldOrProperty;
            m_padding = fieldOrProperty;
            m_type = type;
            m_encodedArgument = new CustomAttributeEncodedArgument();
        }
        // 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);
            }
        }