コード例 #1
0
        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));
        }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
ファイル: RuleContext.cs プロジェクト: JabX/kinetix
        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);
                }
            }
        }
コード例 #4
0
 public void UpdateConstants(long key, RuleConstants ruleConstants)
 {
     Debug.Assert(ruleConstants != null);
     //---
     inMemoryRuleStore[key] = ruleConstants;
 }
コード例 #5
0
ファイル: RuleManager.cs プロジェクト: JabX/kinetix
 public void AddConstants(int key, RuleConstants ruleConstants)
 {
     _ruleConstantsStorePlugin.AddConstants(key, ruleConstants);
 }
コード例 #6
0
 public void AddConstants(int key, RuleConstants ruleConstants)
 {
     Debug.Assert(ruleConstants != null);
     //---
     inMemoryRuleStore[key] = ruleConstants;
 }
コード例 #7
0
        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));
        }