Src/Black.Beard.ComponentModel/ComponentModel/TypeDiscovery.cs
/// <summary>
/// return a list of type that contains specified attibute and filter is valid
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="filterOnAttribute">filter to apply on the attributes</param>
/// <returns></returns>
return a list of type that contains specified attibute and filter is valid
return a list of type that contains specified attibute and filter is valid
public List<Type> GetTypesWithAttributes<T>(Type typebase, Func<T, bool> filterOnAttribute) where T : Attribute
        {
            var result = new List<Type>();
            var assemblies = Assemblies().ToArray();
            result.AddRange(Collect(type =>
            {
                if (typebase == null || typebase.IsAssignableFrom(type))
                {
                    var attributes = TypeDescriptor.GetAttributes(type).OfType<T>().ToArray();
                    if (attributes.Length == 0)
                        return false;
                    foreach (T attribute in attributes)
                        if (filterOnAttribute(attribute))
                            return true;
                }
                return false;
            }, assemblies));
            return result;
        }
public List < Type > GetTypesWithAttributes < T > ( Type typebase , Func < T , bool > filterOnAttribute ) where T : Attribute { var result = new List < Type > ( ) ; var assemblies = Assemblies ( ) . ToArray ( ) ; result . AddRange ( Collect ( type => { if ( typebase == null || typebase . IsAssignableFrom ( type ) ) { var attributes = TypeDescriptor . GetAttributes ( type ) . OfType < T > ( ) . ToArray ( ) ; if ( attributes . Length == 0 ) return false ; foreach ( T attribute in attributes ) if ( filterOnAttribute ( attribute ) ) return true ; } return false ; } , assemblies ) ) ; return result ; }
return a list of type that contains specified attibute and filter is valid
return a list of type that contains specified attibute and filter is valid
None
typebase
Type
filterOnAttribute
Func<T, bool>
filter to apply on the attributes
filter to apply on the attributes
typeparam
None