Esempio n. 1
0
        internal static Attribute[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType, out int count)
        {
            count = 0;
            bool flag = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);

            if (!flag && PseudoCustomAttribute.s_pca.GetValueOrDefault(caType) == null)
            {
                return(null);
            }
            Attribute[] array = new Attribute[PseudoCustomAttribute.s_pcasCount];
            if (flag || caType == (RuntimeType)typeof(InAttribute))
            {
                Attribute customAttribute = InAttribute.GetCustomAttribute(parameter);
                if (customAttribute != null)
                {
                    Attribute[] array2 = array;
                    int         num    = count;
                    count       = num + 1;
                    array2[num] = customAttribute;
                }
            }
            if (flag || caType == (RuntimeType)typeof(OutAttribute))
            {
                Attribute customAttribute = OutAttribute.GetCustomAttribute(parameter);
                if (customAttribute != null)
                {
                    Attribute[] array3 = array;
                    int         num    = count;
                    count       = num + 1;
                    array3[num] = customAttribute;
                }
            }
            if (flag || caType == (RuntimeType)typeof(OptionalAttribute))
            {
                Attribute customAttribute = OptionalAttribute.GetCustomAttribute(parameter);
                if (customAttribute != null)
                {
                    Attribute[] array4 = array;
                    int         num    = count;
                    count       = num + 1;
                    array4[num] = customAttribute;
                }
            }
            if (flag || caType == (RuntimeType)typeof(MarshalAsAttribute))
            {
                Attribute customAttribute = MarshalAsAttribute.GetCustomAttribute(parameter);
                if (customAttribute != null)
                {
                    Attribute[] array5 = array;
                    int         num    = count;
                    count       = num + 1;
                    array5[num] = customAttribute;
                }
            }
            return(array);
        }
        internal static Attribute[] GetCustomAttributes(ParameterInfo parameter, Type caType, out int count)
        {
            count = 0;
            bool flag = (caType == typeof(object)) || (caType == typeof(Attribute));

            if (!flag && (s_pca[caType] == null))
            {
                return(null);
            }
            Attribute[] attributeArray  = new Attribute[s_pcasCount];
            Attribute   customAttribute = null;

            if (flag || (caType == typeof(InAttribute)))
            {
                customAttribute = InAttribute.GetCustomAttribute(parameter);
                if (customAttribute != null)
                {
                    attributeArray[count++] = customAttribute;
                }
            }
            if (flag || (caType == typeof(OutAttribute)))
            {
                customAttribute = OutAttribute.GetCustomAttribute(parameter);
                if (customAttribute != null)
                {
                    attributeArray[count++] = customAttribute;
                }
            }
            if (flag || (caType == typeof(OptionalAttribute)))
            {
                customAttribute = OptionalAttribute.GetCustomAttribute(parameter);
                if (customAttribute != null)
                {
                    attributeArray[count++] = customAttribute;
                }
            }
            if (flag || (caType == typeof(MarshalAsAttribute)))
            {
                customAttribute = MarshalAsAttribute.GetCustomAttribute(parameter);
                if (customAttribute != null)
                {
                    attributeArray[count++] = customAttribute;
                }
            }
            return(attributeArray);
        }