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);
        }
Example #2
0
 public bool Handles(BaseRuleAttribute attribute)
 {
     return(typeof(RangeRuleAttribute).IsAssignableFrom(attribute.GetType()));
 }
Example #3
0
 public bool Handles(BaseRuleAttribute attribute)
 {
     return(typeof(RelationalOperatorAttribute).IsAssignableFrom(attribute.GetType()));
 }