Example #1
0
        public Login(string aXMLFile, SourceLevels engineTraceLevel, SourceLevels ruleBaseTraceLevel)
        {
            try
            {
                IFlowEngine bre = new BREFactoryConsole(engineTraceLevel, ruleBaseTraceLevel).NewBRE(new XBusinessRulesFileDriver(aXMLFile));
                if (bre != null)
                {
                    bre.ResultHandlers += new DispatchRuleResult(HandleBRERuleResult);
                    Increment inc = new Increment();
                    inc.Init(1);

                    bre.RuleContext.SetFactory("Incrementor", inc);

                    Console.Out.WriteLine("Attempt #1: Login locked: {0}", CheckLogin(bre));
                    Console.Out.WriteLine("Attempt #2: Login locked: {0}", CheckLogin(bre));
                    Console.Out.WriteLine("Attempt #3: Login locked: {0}", CheckLogin(bre));
                    if (SHOWSTACK)
                    {
                        Console.Out.WriteLine(bre.RuleContext.ToString());
                    }
                }
                else
                {
                    Console.Error.WriteLine("BRE init failed");
                }
            }
            catch (System.Exception e)
            {
                Console.Error.WriteLine(e.ToString());
            }
        }