public bool IsRuleValid(long idActivityDefinition, object item, RuleConstants constants) { IList <RuleDefinition> rules = _ruleStorePlugin.FindRulesByItemId(idActivityDefinition); RuleContext context = new RuleContext(item, constants); return(_ruleValidatorPlugin.IsRuleValid(idActivityDefinition, rules, context)); }
public RuleContext(object obj, RuleConstants constants) { context = new Dictionary <string, string>(); BeanDefinition definition = BeanDescriptor.GetDefinition(obj.GetType()); BeanPropertyDescriptorCollection properties = definition.Properties; foreach (BeanPropertyDescriptor bean in properties) { context[bean.PropertyName] = bean.GetValue(obj).ToString(); } if (constants != null) { foreach (KeyValuePair <string, string> keyValue in constants.GetValues()) { context.Add(keyValue); } } }
public RuleContext(object obj, RuleConstants constants) { context = new Dictionary <string, object>(); PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(obj); foreach (PropertyDescriptor propDesc in pdc) { object val = propDesc.GetValue(obj); if (val != null) { object value; if (val is IList) { IList valList = (IList)val; value = valList.Cast <object>().Select(v => v.ToString()).ToList(); } else if (val is decimal) { value = val; } else { value = val.ToString(); } context[propDesc.Name] = value; } } if (constants != null) { foreach (KeyValuePair <string, string> keyValue in constants.GetValues()) { context.Add(keyValue.Key, keyValue.Value); } } }
public void UpdateConstants(long key, RuleConstants ruleConstants) { Debug.Assert(ruleConstants != null); //--- inMemoryRuleStore[key] = ruleConstants; }
public void AddConstants(int key, RuleConstants ruleConstants) { _ruleConstantsStorePlugin.AddConstants(key, ruleConstants); }
public void AddConstants(int key, RuleConstants ruleConstants) { Debug.Assert(ruleConstants != null); //--- inMemoryRuleStore[key] = ruleConstants; }
public IList <AccountUser> SelectAccounts(long idActivityDefinition, object item, RuleConstants constants) { IList <SelectorDefinition> selectors = _ruleStorePlugin.FindSelectorsByItemId(idActivityDefinition); RuleContext context = new RuleContext(item, constants); return(_ruleSelectorPlugin.SelectAccounts(idActivityDefinition, selectors, context)); }