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