GetParentDefinition() private static method

private static GetParentDefinition ( EventInfo ev ) : EventInfo
ev EventInfo
return EventInfo
Esempio n. 1
0
 private static bool InternalIsDefined(PropertyInfo element, Type attributeType, bool inherit)
 {
     if (element.IsDefined(attributeType, inherit))
     {
         return(true);
     }
     if (inherit && Attribute.InternalGetAttributeUsage(attributeType).Inherited)
     {
         for (PropertyInfo parentDefinition = Attribute.GetParentDefinition(element); parentDefinition != (PropertyInfo)null; parentDefinition = Attribute.GetParentDefinition(parentDefinition))
         {
             if (parentDefinition.IsDefined(attributeType, false))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 2
0
        private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type type, bool inherit)
        {
            Attribute[] attributes = (Attribute[])element.GetCustomAttributes(type, inherit);
            if (!inherit)
            {
                return(attributes);
            }
            Hashtable types         = new Hashtable(11);
            ArrayList attributeList = new ArrayList();

            Attribute.CopyToArrayList(attributeList, attributes, types);
            for (EventInfo parentDefinition = Attribute.GetParentDefinition(element); parentDefinition != null; parentDefinition = Attribute.GetParentDefinition(parentDefinition))
            {
                Attribute[] customAttributes = Attribute.GetCustomAttributes((MemberInfo)parentDefinition, type, false);
                Attribute.AddAttributesToList(attributeList, customAttributes, types);
            }
            return((Attribute[])attributeList.ToArray(type));
        }
Esempio n. 3
0
        private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type type, bool inherit)
        {
            Attribute[] attributes = (Attribute[])element.GetCustomAttributes(type, inherit);
            if (!inherit)
            {
                return(attributes);
            }
            Dictionary <Type, AttributeUsageAttribute> types = new Dictionary <Type, AttributeUsageAttribute>(11);
            List <Attribute> attributeList = new List <Attribute>();

            Attribute.CopyToArrayList(attributeList, attributes, types);
            for (EventInfo parentDefinition = Attribute.GetParentDefinition(element); parentDefinition != (EventInfo)null; parentDefinition = Attribute.GetParentDefinition(parentDefinition))
            {
                Attribute[] customAttributes = Attribute.GetCustomAttributes((MemberInfo)parentDefinition, type, false);
                Attribute.AddAttributesToList(attributeList, customAttributes, types);
            }
            Array destinationArray = (Array)Attribute.CreateAttributeArrayHelper(type, attributeList.Count);

            Array.Copy((Array)attributeList.ToArray(), 0, destinationArray, 0, attributeList.Count);
            return((Attribute[])destinationArray);
        }
Esempio n. 4
0
 private static bool InternalParamIsDefined(ParameterInfo param, Type type, bool inherit)
 {
     if (param.IsDefined(type, false))
     {
         return(true);
     }
     if (param.Member.DeclaringType == (Type)null || !inherit)
     {
         return(false);
     }
     for (ParameterInfo parentDefinition = Attribute.GetParentDefinition(param); parentDefinition != null; parentDefinition = Attribute.GetParentDefinition(parentDefinition))
     {
         object[] customAttributes = parentDefinition.GetCustomAttributes(type, false);
         for (int index = 0; index < customAttributes.Length; ++index)
         {
             AttributeUsageAttribute attributeUsage = Attribute.InternalGetAttributeUsage(customAttributes[index].GetType());
             if (customAttributes[index] is Attribute && attributeUsage.Inherited)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 5
0
        private static Attribute[] InternalParamGetCustomAttributes(ParameterInfo param, Type type, bool inherit)
        {
            List <Type> list = new List <Type>();

            if (type == (Type)null)
            {
                type = typeof(Attribute);
            }
            object[] customAttributes1 = param.GetCustomAttributes(type, false);
            for (int index = 0; index < customAttributes1.Length; ++index)
            {
                Type type1 = customAttributes1[index].GetType();
                if (!Attribute.InternalGetAttributeUsage(type1).AllowMultiple)
                {
                    list.Add(type1);
                }
            }
            Attribute[] attributeArray1 = customAttributes1.Length != 0 ? (Attribute[])customAttributes1 : Attribute.CreateAttributeArrayHelper(type, 0);
            if (param.Member.DeclaringType == (Type)null || !inherit)
            {
                return(attributeArray1);
            }
            for (ParameterInfo parentDefinition = Attribute.GetParentDefinition(param); parentDefinition != null; parentDefinition = Attribute.GetParentDefinition(parentDefinition))
            {
                object[] customAttributes2 = parentDefinition.GetCustomAttributes(type, false);
                int      elementCount      = 0;
                for (int index = 0; index < customAttributes2.Length; ++index)
                {
                    Type type1 = customAttributes2[index].GetType();
                    AttributeUsageAttribute attributeUsage = Attribute.InternalGetAttributeUsage(type1);
                    if (attributeUsage.Inherited && !list.Contains(type1))
                    {
                        if (!attributeUsage.AllowMultiple)
                        {
                            list.Add(type1);
                        }
                        ++elementCount;
                    }
                    else
                    {
                        customAttributes2[index] = (object)null;
                    }
                }
                Attribute[] attributeArrayHelper = Attribute.CreateAttributeArrayHelper(type, elementCount);
                int         index1 = 0;
                for (int index2 = 0; index2 < customAttributes2.Length; ++index2)
                {
                    if (customAttributes2[index2] != null)
                    {
                        attributeArrayHelper[index1] = (Attribute)customAttributes2[index2];
                        ++index1;
                    }
                }
                Attribute[] attributeArray2 = attributeArray1;
                attributeArray1 = Attribute.CreateAttributeArrayHelper(type, attributeArray2.Length + index1);
                Array.Copy((Array)attributeArray2, (Array)attributeArray1, attributeArray2.Length);
                int length = attributeArray2.Length;
                for (int index2 = 0; index2 < attributeArrayHelper.Length; ++index2)
                {
                    attributeArray1[length + index2] = attributeArrayHelper[index2];
                }
            }
            return(attributeArray1);
        }