System.Reflection.CustomAttributeData.TypeToCustomAttributeEncoding C# (CSharp) Method

TypeToCustomAttributeEncoding() private static method

private static TypeToCustomAttributeEncoding ( Type type ) : CustomAttributeEncoding
type Type
return CustomAttributeEncoding
        private static CustomAttributeEncoding TypeToCustomAttributeEncoding(Type type)
        {
            if (type == typeof(int))
                return CustomAttributeEncoding.Int32;

            if (type.IsEnum)
                return CustomAttributeEncoding.Enum;

            if (type == typeof(string))
                return CustomAttributeEncoding.String;

            if (type == typeof(Type))
                return CustomAttributeEncoding.Type;

            if (type == typeof(object))
                return CustomAttributeEncoding.Object;

            if (type.IsArray)
                return CustomAttributeEncoding.Array;

            if (type == typeof(char))
                return CustomAttributeEncoding.Char;

            if (type == typeof(bool))
                return CustomAttributeEncoding.Boolean;

            if (type == typeof(byte))
                return CustomAttributeEncoding.Byte;

            if (type == typeof(sbyte))
                return CustomAttributeEncoding.SByte;

            if (type == typeof(short))
                return CustomAttributeEncoding.Int16;

            if (type == typeof(ushort))
                return CustomAttributeEncoding.UInt16;

            if (type == typeof(uint))
                return CustomAttributeEncoding.UInt32;

            if (type == typeof(long))
                return CustomAttributeEncoding.Int64;

            if (type == typeof(ulong))
                return CustomAttributeEncoding.UInt64;

            if (type == typeof(float))
                return CustomAttributeEncoding.Float;

            if (type == typeof(double))
                return CustomAttributeEncoding.Double;

            if (type.IsClass)
                return CustomAttributeEncoding.Object;

            if (type.IsInterface)
                return CustomAttributeEncoding.Object;

            if (type.IsValueType)
                return CustomAttributeEncoding.Undefined;

            throw new ArgumentException(Environment.GetResourceString("Argument_InvalidKindOfTypeForCA"), "type");
        }
        private static CustomAttributeType InitCustomAttributeType(Type parameterType, Module scope)

Usage Example

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