Exemple #1
0
        private void GenerateBizRuleSetFromDBRuleset()
        {
            foreach (var dbRule in dbRulesSet.RuleSet_Rule)
            {
                var dbCondition       = dbRule.Rule.Condition;
                var conditionInstance = ReflectionHelper.GetClassInstance(dbCondition.AssemblyInfo.Name, dbCondition.AssemblyInfo.Path, dbCondition.ClassName);

                var dbAction       = dbRule.Rule.Action;
                var actionInstance = ReflectionHelper.GetClassInstance(dbAction.AssemblyInfo.Name, dbAction.AssemblyInfo.Path, dbAction.ClassName);

                if (conditionInstance != null)
                {
                    if (actionInstance != null)
                    {
                        if (ReflectionHelper.ImplementsInterface(conditionInstance, typeof(ICondition)))
                        {
                            if (ReflectionHelper.ImplementsInterface(actionInstance, typeof(IAction)))
                            {
                                Biz_Rule rule = new Biz_Rule();
                                rule.Condition           = (ICondition)conditionInstance;
                                rule.Action              = (IAction)actionInstance;
                                rule.Action.ActionEvent += Action_ActionEvent;
                                if (Biz_Rules == null)
                                {
                                    Biz_Rules = new List <Biz_Rule>();
                                }
                                Biz_Rules.Add(rule);
                            }
                            else
                            {
                                throw (new Exception("Action class '" + dbAction.ClassName + "' is not of type IAction"));
                            }
                        }
                        else
                        {
                            throw (new Exception("Condition class '" + dbAction.ClassName + "' is not of type ICondition"));
                        }
                    }
                    else
                    {
                        throw (new Exception("Action class '" + dbAction.ClassName + "' colud not be found in assembly '" + dbAction.AssemblyInfo.Name + "'"));
                    }
                }
                else
                {
                    throw (new Exception("Condition class '" + dbCondition.ClassName + "' colud not be found in assembly '" + dbCondition.AssemblyInfo.Name + "'"));
                }
            }
        }
Exemple #2
0
 public Biz_RuleSet(Biz_Rule rule)
 {
     Biz_Rules = new List <Biz_Rule>();
     Biz_Rules.Add(rule);
 }