public NotificationManager(INotificationHandler[] handlers) { _handlers = handlers.Select(h => new { Handler = h, Type = (HandleNotificationTypeAttribute)h.GetType().GetCustomAttributes(typeof(HandleNotificationTypeAttribute), false).FirstOrDefault(), }) .Where(h => h.Type != null) .ToLookup(h => h.Type.Type, h => h.Handler, StringComparer.OrdinalIgnoreCase); }