System.MonoCustomAttrs.IsDefined C# (CSharp) Метод

IsDefined() статический приватный Метод

static private IsDefined ( ICustomAttributeProvider obj, Type attributeType, bool inherit ) : bool
obj ICustomAttributeProvider
attributeType Type
inherit bool
Результат bool
		internal static bool IsDefined (ICustomAttributeProvider obj, Type attributeType, bool inherit)
		{
			if (attributeType == null)
				throw new ArgumentNullException ("attributeType");

			if (IsUserCattrProvider (obj))
				return obj.IsDefined (attributeType, inherit);

			if (IsDefinedInternal (obj, attributeType))
				return true;

			object[] pseudoAttrs = GetPseudoCustomAttributes (obj, attributeType);
			if (pseudoAttrs != null) {
				for (int i = 0; i < pseudoAttrs.Length; ++i)
					if (attributeType.IsAssignableFrom (pseudoAttrs [i].GetType ()))
						return true;
			}

#if ONLY_1_1
			if (inherit) {
				AttributeUsageAttribute usage = RetrieveAttributeUsage (attributeType);
				if (!usage.Inherited)
					inherit = false;
			}
#endif

			// FIXME (bug #82431):
			// on 2.0 profile we should always walk the inheritance
			// chain and base the behavior on the inheritance level:
			//
			// 0  : return true if "attributeType" is assignable from
			// any of the custom attributes
			//
			// > 0: return true if "attributeType" is assignable from
			// any of the custom attributes and AttributeUsageAttribute
			// .Inherited of the assignable attribute is true

			ICustomAttributeProvider btype;
			if (inherit && ((btype = GetBase (obj)) != null))
				return IsDefined (btype, attributeType, inherit);

			return false;
		}

Usage Example

Пример #1
0
        internal static bool IsDefined(ICustomAttributeProvider obj, Type attributeType, bool inherit)
        {
            if (attributeType == null)
            {
                throw new ArgumentNullException("attributeType");
            }
            if (MonoCustomAttrs.IsUserCattrProvider(obj))
            {
                return(obj.IsDefined(attributeType, inherit));
            }
            if (MonoCustomAttrs.IsDefinedInternal(obj, attributeType))
            {
                return(true);
            }
            object[] pseudoCustomAttributes = MonoCustomAttrs.GetPseudoCustomAttributes(obj, attributeType);
            if (pseudoCustomAttributes != null)
            {
                for (int i = 0; i < pseudoCustomAttributes.Length; i++)
                {
                    if (attributeType.IsAssignableFrom(pseudoCustomAttributes[i].GetType()))
                    {
                        return(true);
                    }
                }
            }
            ICustomAttributeProvider @base;

            return(inherit && (@base = MonoCustomAttrs.GetBase(obj)) != null && MonoCustomAttrs.IsDefined(@base, attributeType, inherit));
        }
All Usage Examples Of System.MonoCustomAttrs::IsDefined