/// <summary> /// /// </summary> /// <typeparam name="TDescriptor"></typeparam> /// <typeparam name="TCollection"></typeparam> /// <param name="attributeProvider"></param> /// <param name="comparisonType"></param> /// <param name="inherit"></param> /// <returns></returns> public static TCollection RetrieveMemberDescriptors <TDescriptor, TCollection>(ICustomAttributeProvider attributeProvider, Type comparisonType, bool inherit = false) where TDescriptor : AttributeMemberDescriptor where TCollection : ReadOnlyListCollection <TDescriptor> { var _descriptors = AttributeMemberHelpers.RetrieveMembers(attributeProvider, comparisonType, inherit) .Select(attr => AttributeMemberDescriptor.Initializer.Initialize <TDescriptor>(attr)); return(ReadOnlyListCollection <TDescriptor> .Initializer.Initialize <TCollection>(_descriptors)); }
/// <summary> /// /// </summary> /// <param name="instance"></param> /// <param name="comparisonType"></param> /// <param name="inherit"></param> /// <returns></returns> public static Attribute[] RetrieveMembers(object instance, Type comparisonType, bool inherit = false) { if (null == instance) { throw new ArgumentNullException("instance"); } return(AttributeMemberHelpers.RetrieveMembers(instance.GetType(), comparisonType, inherit)); }
/// <summary> /// /// </summary> /// <typeparam name="TDescriptor"></typeparam> /// <typeparam name="TCollection"></typeparam> /// <param name="instance"></param> /// <param name="inherit"></param> /// <returns></returns> public static TCollection RetrieveMemberDescriptors <TDescriptor, TCollection>(object instance, bool inherit = false) where TDescriptor : AttributeMemberDescriptor where TCollection : ReadOnlyListCollection <TDescriptor> { var _descriptors = AttributeMemberHelpers.RetrieveMembers(instance, inherit) .Select(attr => AttributeMemberDescriptor.Initializer.Initialize <TDescriptor>(attr)); return(ReadOnlyListCollection <TDescriptor> .Initializer.Initialize <TCollection>(_descriptors)); }
/// <summary> /// /// </summary> /// <param name="attributeProvider"></param> /// <param name="comparisonType"></param> /// <param name="inherit"></param> /// <returns></returns> public static Attribute RetrieveMember(ICustomAttributeProvider attributeProvider, Type comparisonType, bool inherit = false) { var _attrs = AttributeMemberHelpers.RetrieveMembers(attributeProvider, comparisonType, inherit); if (null != _attrs && 0 < _attrs.Length) { return(_attrs[0]); } throw new NullReferenceException(string.Format("A '{0}' attribute does not exist.", comparisonType.FullName)); }