/// <summary> /// Searches a type/method/property/field for attributes of the specified type, matching the /// specified filter. /// </summary> /// <typeparam name="TAttribute">The type of attribute (may also be a base class).</typeparam> /// <param name="member">The type/method/property/field to find attributes on.</param> /// <param name="inherit">True to include inherited attributes in the search.</param> /// <param name="filter">A filter that restricts the results of the search.</param> /// <returns>A list of matching attributes.</returns> public static List <TAttribute> GetAttributes <TAttribute>(MemberInfo member, bool inherit, Predicate <TAttribute> filter) where TAttribute : Attribute { return(CollectionUtils.Map <TAttribute, TAttribute, List <TAttribute> >( CollectionUtils.Select <TAttribute>(member.GetCustomAttributes(typeof(TAttribute), inherit), filter), delegate(TAttribute obj) { return obj; })); }
/// <summary> /// Returns the set of resources whose name matches the specified regular expression. /// </summary> /// <param name="regex">A regular expression to be used to select matching resources.</param> /// <returns>An array of fully qualified resource names that match the specified regular expression.</returns> public string[] FindResources(Regex regex) { Platform.CheckForNullReference(regex, @"regex"); var matches = new List <string>(); foreach (var asm in _assemblies) { matches.AddRange(CollectionUtils.Select(asm.GetManifestResourceNames(), result => regex.Match(result).Success)); } // include the fallback if (_fallbackResolver != null) { matches.AddRange(_fallbackResolver.FindResources(regex)); } return(CollectionUtils.Unique(matches).ToArray()); }
/// <summary> /// Returns the set of resources whose name matches the specified regular expression. /// </summary> /// <param name="regex"></param> /// <returns></returns> public string[] FindResources(Regex regex) { List <string> matches = new List <string>(); foreach (Assembly asm in _assemblies) { matches.AddRange( CollectionUtils.Select(asm.GetManifestResourceNames(), delegate(string res) { return(regex.Match(res).Success); })); } // include the fallback if (_fallbackResovler != null) { matches.AddRange(_fallbackResovler.FindResources(regex)); } return(CollectionUtils.Unique(matches).ToArray()); }