using System; using System.Linq; using System.Reflection; using System.Collections.Generic; namespace FilterAPI.Handlers { public class FilterAssembly { public static IEnumerable> FindHandlers() where MsgHandlerAttribute : Attribute { return (from Method in AppDomain.CurrentDomain.GetAssemblies() .Where(Assembly => !Assembly.GlobalAssemblyCache) .SelectMany(Types => Types.GetTypes()) .SelectMany(Methods => Methods.GetMethods()) let CustomAttribute = Attribute.GetCustomAttribute(Method, typeof(MsgHandlerAttribute), false) as MsgHandlerAttribute where CustomAttribute != null select new Combine(CustomAttribute, Method)); } } }