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

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

static private GetPseudoCustomAttributes ( ICustomAttributeProvider obj, Type attributeType ) : object[]
obj ICustomAttributeProvider
attributeType Type
Результат object[]
		internal static object[] GetPseudoCustomAttributes (ICustomAttributeProvider obj, Type attributeType) {
			object[] pseudoAttrs = null;

			/* FIXME: Add other types */
			if (obj is MonoMethod)
				pseudoAttrs = ((MonoMethod)obj).GetPseudoCustomAttributes ();
			else if (obj is FieldInfo)
				pseudoAttrs = ((FieldInfo)obj).GetPseudoCustomAttributes ();
			else if (obj is ParameterInfo)
				pseudoAttrs = ((ParameterInfo)obj).GetPseudoCustomAttributes ();
			else if (obj is Type)
				pseudoAttrs = ((Type)obj).GetPseudoCustomAttributes ();

			if ((attributeType != null) && (pseudoAttrs != null)) {
				for (int i = 0; i < pseudoAttrs.Length; ++i)
					if (attributeType.IsAssignableFrom (pseudoAttrs [i].GetType ()))
						if (pseudoAttrs.Length == 1)
							return pseudoAttrs;
						else
							return new object [] { pseudoAttrs [i] };
				return new object [0];
			}
			else
				return pseudoAttrs;
		}

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::GetPseudoCustomAttributes