List <IHandlerAttribute <T> > GetAttributes <T>(IHandleCommands handler) { // TODO bad bad performance due to reflection. Probably want to cache all these look ups? var customAttributes = new List <IHandlerAttribute <T> >(); var allAttributes = Attribute.GetCustomAttributes(handler.GetType().GetMethod("Handle")); foreach (var attribute in allAttributes) { var attributeType = attribute.GetType(); if (attributeType.GetInterfaces().Any(i => i.Name == "IHandleAttribute")) { var attributeFromFactory = _commandHandlerFactory.CreateAttribute <T>(attributeType); attributeFromFactory.Order = GetPriority(attribute); customAttributes.Add(attributeFromFactory); } } return(customAttributes); }