public static IHandler FindHandler(this Dictionary <Type, IHandler> handlerMapping, BaseRuleAttribute attribute)
        {
            var handler = handlerMapping.Values.SingleOrDefault(h => h.Handles(attribute));

            if (handler == null)
            {
                var attrType = attribute.GetType();
                throw new HandlerNotFoundException(attrType.Name, attrType.FullName);
            }
            return(handler);
        }
Пример #2
0
 public bool Handles(BaseRuleAttribute attribute)
 {
     return(typeof(RangeRuleAttribute).IsAssignableFrom(attribute.GetType()));
 }
Пример #3
0
 public bool Handles(BaseRuleAttribute attribute)
 {
     return(typeof(RelationalOperatorAttribute).IsAssignableFrom(attribute.GetType()));
 }