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

GetCustomAttributes() public static method

public static GetCustomAttributes ( MemberInfo target ) : IList
target MemberInfo
return IList
        public static IList<CustomAttributeData> GetCustomAttributes(MemberInfo target)
        {
            if (target == null)
                throw new ArgumentNullException("target");

            IList<CustomAttributeData> cad = GetCustomAttributes(target.Module, target.MetadataToken);

            int pcaCount = 0;
            Attribute[] a = null;
            if (target is RuntimeType)
                a = PseudoCustomAttribute.GetCustomAttributes((RuntimeType)target, typeof(object), false, out pcaCount);
            else if (target is RuntimeMethodInfo)
                a = PseudoCustomAttribute.GetCustomAttributes((RuntimeMethodInfo)target, typeof(object), false, out pcaCount);
            else if (target is RuntimeFieldInfo)
                a = PseudoCustomAttribute.GetCustomAttributes((RuntimeFieldInfo)target, typeof(object), out pcaCount);

            if (pcaCount == 0)
                return cad;

            CustomAttributeData[] pca = new CustomAttributeData[cad.Count + pcaCount];
            cad.CopyTo(pca, pcaCount);
            for (int i = 0; i < pcaCount; i++)
            {
                if (PseudoCustomAttribute.IsSecurityAttribute(a[i].GetType()))
                    continue;

                pca[i] = new CustomAttributeData(a[i]);
            }

            return Array.AsReadOnly(pca);
        }

Same methods

CustomAttributeData::GetCustomAttributes ( Assembly target ) : IList
CustomAttributeData::GetCustomAttributes ( Module target ) : IList
CustomAttributeData::GetCustomAttributes ( Module module, int tkTarget ) : IList
CustomAttributeData::GetCustomAttributes ( ParameterInfo target ) : IList

Usage Example

Esempio n. 1
0
 public override IList <CustomAttributeData> GetCustomAttributesData()
 {
     return(CustomAttributeData.GetCustomAttributes(this));
 }
All Usage Examples Of System.Reflection.CustomAttributeData::GetCustomAttributes