Exemplo n.º 1
0
        public decimal GetTotal()
        {
            List <OrderLine> orderLines    = new List <OrderLine>();
            List <OrderLine> newOrderLines = new List <OrderLine>();

            orderLines.AddRange(_products.GroupBy(e => e.Code)
                                .Select(d => new OrderLine(Guid.NewGuid(), d.First(), d.Count(), d.First().DefaultPrice)));

            foreach (var orderline in orderLines)
            {
                IPricingRule rule         = new DefaultRule();
                var          pricingRules = _productRuleBinder.GetRules(orderline.Product);
                foreach (var prule in pricingRules)
                {
                    if (prule.IsApplicable(orderline))
                    {
                        rule = prule;
                        break;
                    }
                }

                var price = rule.PriceRuleFunc.Compile().Invoke(orderline).Value;
                newOrderLines.Add(new OrderLine(orderline.Id, orderline.Product, orderline.Quantity, price));
            }

            var order = Order.Create(newOrderLines);

            return(order.TotalPrice);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Contructor for 2D cellular automaton.
        /// </summary>
        /// <param name="width">Width of array of cells</param>
        /// <param name="height">Height of array of cells</param>
        /// <param name="rules">Rules for cellular automaton</param>
        /// <param name="name">Name of instance of cellular automaton</param>
        public CellularAutomaton2D(int width, int height, DefaultRule rules, string name = "DefaultName")
        {
            Size = new int[2] {
                width, height
            };

            if (width <= 0 || height <= 0)
            {
                throw new ArgumentOutOfRangeException("Width and height of cellular automat have to be positive number");
            }

            if (rules == null)
            {
                throw new ArgumentException("Parameter rules is null.");
            }

            this.rules = rules;

            Name = name;

            cells = new List <List <Cell> >();

            for (int i = 0; i < height; i++)
            {
                cells.Add(new List <Cell>());

                for (int j = 0; j < width; j++)
                {
                    cells[i].Add(new Cell(rules.DefaultState));
                }
            }
        }
Exemplo n.º 3
0
        private ConcurrencyRule GetRule()
        {
            ConcurrencyRule rule       = new ConcurrencyRule();
            DefaultRule     endOfChain = new DefaultRule();

            rule.SetSuccessor(endOfChain);
            return(rule);
        }
Exemplo n.º 4
0
    /*void OnDestroy()
     * {
     *
     * }*/

    /*void Update()
     * {
     *  if (Input.GetKeyUp(KeyCode.C))
     *  {
     *
     *  }
     * }*/
    private int GetMyselfIndex()
    {
        if (GameApp.Instance.PlayerData != null && !GameApp.Instance.IsFightingRobot)
        {
            for (int i = 0; i < GameApp.Instance.CurRoomPlayerLst.Count; i++)
            {
                if (DefaultRule.PlayerIDToAccountID(GameApp.Instance.CurRoomPlayerLst[i].id) == GameApp.AccountID)
                {
                    return(i);
                }
            }
        }
        return(0);
    }
Exemplo n.º 5
0
        private GapReservationRule GetGapRule(int gapNotAllowed)
        {
            var repo = Substitute.For <IGapRuleRepository>();

            repo.GetGapRules().Returns(new List <GapRule>
            {
                new GapRule
                {
                    GapSize = gapNotAllowed
                }
            });
            GapReservationRule rule        = new GapReservationRule(repo);
            DefaultRule        defaultRule = new DefaultRule();

            rule.SetSuccessor(defaultRule);
            return(rule);
        }
Exemplo n.º 6
0
    public void RefreshRoomInfo(bool NoRoom = false /*int RoomID,int StageID*/)
    {
        if ((GameApp.Instance.CurRoomPlayerLst.Count > 0 && DefaultRule.PlayerIDToAccountID(GameApp.Instance.CurRoomPlayerLst[0].id) == GameApp.AccountID) ||
            (GameApp.Instance.PlayerData == null) ||
            NoRoom)
        {
            IsOwner = true;
        }

        GameApp.Instance.CurRoomPlayerLoadStateLst.Clear();
        for (int i = 0; i < TeamMembers.Length; i++)
        {
            TeamMembers[i].Set("", 0, IsOwner ? ETeamMemberType.eInvite : ETeamMemberType.eWaitJoin);
        }
        for (int i = 0; i < GameApp.Instance.CurRoomPlayerLst.Count; i++)
        {
            PVE_Room_Player player = GameApp.Instance.CurRoomPlayerLst[i];

            GameApp.Instance.CurRoomPlayerLoadStateLst.Add(player.id, 0);

            ETeamMemberType TMType = ETeamMemberType.eNull;

            if (i == 0)
            {
                RoomName.text = StringBuilderTool.ToInfoString(player.name, "的房间");
                TMType        = ETeamMemberType.eOwner;
            }
            else
            {
                if (player.ready)
                {
                    TMType = ETeamMemberType.eBeReady;
                }
                else
                {
                    TMType = ETeamMemberType.eNotReady;
                }
            }

            TeamMembers[i].Set(player.name, (int)player.icon, TMType);
        }

        BeginFightBtn.isEnabled = (IsOwner && (GameApp.Instance.CurRoomPlayerLst.Count > 1));
    }
Exemplo n.º 7
0
    public void Init(common.PVE_Room_Player rp)
    {
        if (rp == null)
        {
            return;
        }
        RecordRP = rp;

        if (Bg != null)
        {
            if (DefaultRule.PlayerIDToAccountID(rp.id) == GameApp.AccountID)
            {
                Bg.spriteName = MyselfBgSpriteName;
            }
            else
            {
                Bg.spriteName = OtherBgSpriteName;
            }
        }

        if (HeadPortrait != null)
        {
            RecordRP.icon = Math.Max(RecordRP.icon, 1);
            RoleConfig rc = null;
            if (CsvConfigTables.Instance.RoleCsvDic.TryGetValue((int)RecordRP.icon, out rc))
            {
                HeadPortrait.spriteName = (useBigHeadPortrait ? rc.PortraitEx : rc.Portrait);
            }
        }

        if (Name != null)
        {
            Name.text = RecordRP.name;
        }

        if (Score != null)
        {
            Score.text = RecordRP.score.ToString();
        }
    }
Exemplo n.º 8
0
    public void AnswerQuestionResult(ulong playerID, bool _isRight)
    {
        isRight = _isRight;

        if (CurType == ELibraryType.eBoss && !IsChallenger)
        {
            if (isRight)
            {
                RightNum++;

                if (RightNum == 2)
                {
                    GameApp.Instance.CommonHintDlg.OpenHintBox(StringBuilderTool.ToInfoString(CurChallengerName, "答对两题!挑战魔王成功!"));
                    StartCoroutine("ChallengeBossSucceed");
                }
                else
                {
                    GameApp.Instance.CommonHintDlg.OpenHintBox(StringBuilderTool.ToInfoString(CurChallengerName, "答对一题!"));
                    StartCoroutine("Attack");
                    SetNewQuestion(1.5f);
                }
            }
            else
            {
                ErrorNum++;

                if (ErrorNum == 2)
                {
                    GameApp.Instance.CommonHintDlg.OpenHintBox(StringBuilderTool.ToInfoString(CurChallengerName, "答错两题!挑战魔王失败!"));
                    StartCoroutine("ChallengeBossFailure");
                }
                else
                {
                    GameApp.Instance.CommonHintDlg.OpenHintBox(StringBuilderTool.ToInfoString(CurChallengerName, "答错一题!"));
                    StartCoroutine("Attack");
                    SetNewQuestion(1.5f);
                }
            }

            return;
        }

        AnswerPlayerNum++;

        int Index = GetMyselfIndex();

        if (GameApp.Instance.CurRoomPlayerLst[Index].win_num > 0)
        {
            Show(false);
            return;
        }

        if (DefaultRule.PlayerIDToAccountID(playerID) == GameApp.AccountID)
        {
            switch (CurType)
            {
            case ELibraryType.eNormal:
            {
                StartCoroutine("DelayShowSettlement");
            }
            break;

            case ELibraryType.eBoss:
            {
                if (RightNum >= 2)
                {
                    StartCoroutine("ChallengeBossSucceed");
                }
                else if (ErrorNum >= 2)
                {
                    StartCoroutine("ChallengeBossFailure");
                }
                else
                {
                    StartCoroutine("Attack");
                    SetNewQuestion(1.5f);
                }
            }
            break;
            }
        }
        else
        {
            for (int i = 0; i < GameApp.Instance.CurRoomPlayerLst.Count; i++)
            {
                if (GameApp.Instance.CurRoomPlayerLst[i].id == playerID)
                {
                    Index = i;
                    break;
                }
            }
            for (int j = 0; j < StateArrays[Index].Length; j++)
            {
                StateArrays[Index][j].spriteName = (isRight ? "i-dui" : "i-cuo");
            }
        }

        int Score = isRight ? GameApp.Instance.GetParameter("AnswerRightScore") : 0;
        int Gold  = isRight ? GameApp.Instance.GetParameter("AnswerRightGold") : 0;

        ScoreReward[Index].text = StringBuilderTool.ToString("+", Score);
        GoldReward[Index].text  = StringBuilderTool.ToString("+", Gold);
    }
        /// <summary>
        /// Gets the rule.
        /// </summary>
        /// <param name="ruleElement">The rule element.</param>
        /// <returns></returns>
        private IRule GetRule(XmlNode ruleElement)
        {
            if (ruleElement == null)
            {
                throw new ArgumentNullException("ruleElement");
            }

            if (ruleElement.Name != "rule")
            {
                throw new RuleSetException("The node is not a \"rule\".");
            }

            bool enabled = true;             // from schema definition

            if (ruleElement.Attributes["enabled"] != null)
            {
                enabled = XmlConvert.ToBoolean(ruleElement.Attributes["enabled"].Value);
            }

            // if it is not enabled there is no reason to continue processing
            if (!enabled)
            {
                return(null);
            }

            string name           = String.Empty;
            bool   stopProcessing = false;           // from schema definition
            string patternSyntax  = "ECMAScript";    // from schema definiton

            if (ruleElement.Attributes["name"] != null)
            {
                name = ruleElement.Attributes["name"].Value;
            }

            if (ruleElement.Attributes["stopProcessing"] != null)
            {
                stopProcessing = XmlConvert.ToBoolean(ruleElement.Attributes["stopProcessing"].Value);
            }

            if (ruleElement.Attributes["patternSyntax"] != null)
            {
                patternSyntax = ruleElement.Attributes["patternSyntax"].Value;
            }

            XmlNode matchElement           = ruleElement.SelectSingleNode("match");
            XmlNode conditionsElement      = ruleElement.SelectSingleNode("conditions");
            XmlNode serverVariablesElement = ruleElement.SelectSingleNode("serverVariables");
            XmlNode actionElement          = ruleElement.SelectSingleNode("action");

            IRuleFlagProcessor ruleFlags = new RuleFlagProcessor();
            IRule rule = new DefaultRule();

            rule.Name = name;

            // <match />
            Pattern match = GetMatch(matchElement, ref ruleFlags);

            // <condition />
            IEnumerable <ICondition> conditions = GetConditions(conditionsElement);

            // <serverVariables />
            foreach (var flag in GetServerVariables(serverVariablesElement))
            {
                ruleFlags.Add(flag);
            }

            // <action />
            IRuleAction action = GetAction(actionElement, match, ref ruleFlags);

            // <rule />
            rule.Init(conditions, action, ruleFlags);

            return(rule);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Execute the rules within the <see cref="RuleTypeCollection{TActionContext,TTypeEnum}"/>
        /// </summary>
        /// <param name="context"></param>
        /// <param name="stopOnFirst"></param>
        public void Execute(TContext context, bool stopOnFirst)
        {
            LastAppliedRules = new List <IRule>();

            bool doDefault = true;

            try
            {
                foreach (var theRule in _exemptRuleList)
                {
                    bool ruleApplied;
                    bool ruleSuccess;

                    context.Name = theRule.Name;
                    theRule.Execute(context, false, out ruleApplied, out ruleSuccess);

                    if (ruleApplied)
                    {
                        LastAppliedRules.Add(theRule);
                        Platform.Log(LogLevel.Info, "Exempt rule found that applies for {0}, ignoring action.", Type.ToString());
                        return;
                    }
                }

                foreach (var theRule in _ruleList)
                {
                    bool ruleApplied;
                    bool ruleSuccess;

                    context.Name = theRule.Name;
                    theRule.Execute(context, false, out ruleApplied, out ruleSuccess);

                    if (ruleApplied && ruleSuccess)
                    {
                        LastAppliedRules.Add(theRule);

                        if (stopOnFirst)
                        {
                            return;
                        }

                        doDefault = false;
                    }
                }

                if (doDefault && DefaultRule != null)
                {
                    bool ruleApplied;
                    bool ruleSuccess;

                    context.Name = DefaultRule.Name;
                    DefaultRule.Execute(context, true, out ruleApplied, out ruleSuccess);
                    if (ruleApplied)
                    {
                        LastAppliedRules.Add(DefaultRule);
                    }

                    if (!ruleSuccess)
                    {
                        Platform.Log(LogLevel.Error, "Unable to apply default rule of type {0}", Type);
                    }
                }
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Error, e, "Unexpected exception when applying rule of type: {0}", Type);
            }
        }
        /// <summary>
        /// Refreshes the rules.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public void RefreshRules(TextReader reader)
        {
            // put a lock on the refresh process so that only one refresh can happen at a time
            lock (_refreshLock)
            {
                Manager.LogEnabled = false;
                Manager.LogPath    = null;

                string tempBase                 = PhysicalBase;
                string tempLogPath              = null;
                int    tempLogLevel             = 0;
                int    tempMaxInternalTransfers = 10;
                bool   tempEngineEnabled        = false;

                string             line;
                IList <ICondition> conditions   = new List <ICondition>(0);
                IList <IRule>      rules        = new List <IRule>();
                IList <IRule>      outputRules  = new List <IRule>();
                IList <string>     unknownLines = new List <string>();
                ModuleFactory      modules      = new ModuleFactory();

                while (reader.Peek() >= 0)
                {
                    line = reader.ReadLine().Trim();

                    if (String.IsNullOrEmpty(line))
                    {
                        // just plain old ignore empty lines no logging or anything
                        continue;
                    }
                    else if (line[0] == '#')
                    {
                        Manager.LogIf(tempLogLevel >= 4, "Comment: " + line, "Rule Processing");
                    }
                    else if (RewriteEngineLine.IsMatch(line))
                    {
                        #region RewriteEngine

                        Match  match       = RewriteEngineLine.Match(line);
                        string engineState = match.Groups["state"].Value;

                        // by default the engine is turned off
                        if (String.IsNullOrEmpty(engineState) || String.Equals(engineState, "off", StringComparison.OrdinalIgnoreCase))
                        {
                            rules.Clear();
                            tempEngineEnabled = false;

                            // don't bother processing any other rules if the engine is disabled
                            break;
                        }
                        else
                        {
                            tempEngineEnabled = true;
                        }

                        Manager.LogIf(tempLogLevel >= 3, "RewriteEngine: " + (tempEngineEnabled ? "Enabled" : "Disabled"), "Rule Processing");

                        #endregion
                    }
                    else if (RewriteOptionsLine.IsMatch(line))
                    {
                        #region RewriteOptions

                        Match match     = RewriteOptionsLine.Match(line);
                        Group variables = match.Groups["var"];

                        if (variables.Success)
                        {
                            foreach (Capture var in variables.Captures)
                            {
                                string[] parts = var.Value.Split(new[] { '=' }, 2);
                                bool     variableUnderstood = false;

                                if (parts.Length == 2)
                                {
                                    switch (parts[0])
                                    {
                                    case "inherit":
                                        break;

                                    // obsolete in 2.1 mod_rewrite
                                    case "MaxRedirects":
                                        Manager.LogIf(tempLogLevel >= 1, "MaxRedirects is obsolete", "Obsolete");

                                        int maxInternalTransfers;
                                        if (Int32.TryParse(parts[1], out maxInternalTransfers))
                                        {
                                            tempMaxInternalTransfers = maxInternalTransfers;
                                            variableUnderstood       = true;
                                        }
                                        break;
                                    }
                                }

                                if (!variableUnderstood)
                                {
                                    Manager.LogIf(tempLogLevel >= 4, "Not Understood: " + var.Value, "Unknown");
                                }
                            }
                        }

                        #endregion
                    }
                    else if (RewriteBaseLine.IsMatch(line))
                    {
                        #region RewriteBase

                        Match match = RewriteBaseLine.Match(line);
                        tempBase = match.Groups["base"].Value;

                        Manager.LogIf(tempLogLevel >= 3, "RewriteBase: " + VirtualBase, "Rule Processing");

                        #endregion
                    }
                    else if (RewriteModuleLine.IsMatch(line))
                    {
                        #region RewriteModule

                        Match  match      = RewriteModuleLine.Match(line);
                        string moduleName = match.Groups["name"].Value;
                        string moduleType = match.Groups["type"].Value;
                        Type   module     = Type.GetType(moduleType, false, true);

                        if (module == null)
                        {
                            module = BuildManager.GetType(moduleType, false, true);
                        }

                        if (module == null)
                        {
                            Manager.LogIf(tempLogLevel >= 3, "RewriteModule: Error finding " + moduleType, "Rule Processing");
                        }
                        else
                        {
                            // add the module to the list
                            modules.AddModule(moduleName, module);

                            Manager.LogIf(tempLogLevel >= 3, "RewriteModule: " + moduleType, "Rule Processing");
                        }

                        #endregion
                    }
                    else if (RewriteLogLine.IsMatch(line))
                    {
                        #region RewriteLog

                        Match match = RewriteLogLine.Match(line);
                        tempLogPath = match.Groups["location"].Value;
                        tempLogPath = NormalizeLogLocation(tempLogPath);

                        Manager.LogIf(tempLogLevel >= 3, "RewriteLog: " + tempLogPath, "Rule Processing");

                        #endregion
                    }
                    else if (RewriteLogLevelLine.IsMatch(line))
                    {
                        #region RewriteLogLevel

                        Match match    = RewriteLogLevelLine.Match(line);
                        int   logLevel = 1;

                        if (!Int32.TryParse(match.Groups["level"].Value, out logLevel))
                        {
                            tempLogLevel = 0;
                            Manager.LogIf(tempLogLevel >= 3, "RewriteLogLevel: " + match.Groups["level"].Value + " not understood.", "Rule Processing");
                        }
                        else
                        {
                            tempLogLevel = logLevel;
                        }

                        Manager.LogIf(tempLogLevel >= 3, "RewriteLogLevel: " + logLevel, "Rule Processing");

                        #endregion
                    }
                    else if (RewriteCondLine.IsMatch(line))
                    {
                        #region RewriteCond

                        Match match = RewriteCondLine.Match(line);

                        string module1 = match.Groups["module1"].Value;
                        string module2 = match.Groups["module2"].Value;

                        Type moduleType1 = null;
                        Type moduleType2 = null;

                        // set the types of the first module
                        if (modules.ContainsName(module1))
                        {
                            moduleType1 = modules.GetModule(module1);
                        }

                        // make sure the module is of the right type
                        if (moduleType1 != null && moduleType1.GetInterface("ICondition", false) == null)
                        {
                            moduleType1 = null;
                        }

                        // set the types of the second module
                        if (modules.ContainsName(module2))
                        {
                            moduleType2 = modules.GetModule(module2);
                        }

                        // make sure the module is of the right type
                        if (moduleType2 != null && moduleType2.GetInterface("IConditionTestValue", false) == null)
                        {
                            moduleType2 = null;
                        }

                        try
                        {
                            RegexOptions            patternOptions = Manager.RuleOptions;
                            IConditionFlagProcessor flags;

                            if (match.Groups["flags"] != null)
                            {
                                flags = SplitConditionFlags(match.Groups["flags"].Value);
                            }
                            else
                            {
                                flags = new ConditionFlagProcessor();
                            }

                            // check to see if the pattern should ignore the case when testing
                            if (ConditionFlagsProcessor.HasNoCase(flags))
                            {
                                patternOptions |= RegexOptions.IgnoreCase;
                            }

                            string test    = match.Groups["test"].Value;
                            string pattern = match.Groups["pattern"].Value;
                            IConditionTestValue testValue;
                            ICondition          condition;

                            // create the second module
                            if (moduleType2 == null)
                            {
                                testValue = GetConditionTestValue(ref test);
                            }
                            else
                            {
                                testValue = Activator.CreateInstance(moduleType2) as IConditionTestValue;
                            }

                            // create the first module
                            if (moduleType1 == null)
                            {
                                condition = GetCondition(pattern);
                            }
                            else
                            {
                                condition = Activator.CreateInstance(moduleType1) as ICondition;
                            }

                            // initialize the modules
                            testValue.Init(test);
                            condition.Init(new Pattern(pattern, patternOptions), testValue, flags);

                            // add condition to next rule that shows up
                            conditions.Add(condition);
                        }
                        catch (Exception exc)
                        {
                            if (tempLogLevel >= 3)
                            {
                                Manager.Log("RewriteCond: " + exc.Message, "Error");
                            }
                            else
                            {
                                Manager.Log("RewriteCond: " + exc, "Error");
                            }
                        }
                        finally
                        {
                            Manager.LogIf(tempLogLevel >= 3, "RewriteCond: " + match.Groups["test"].Value + " " + match.Groups["pattern"].Value + " [" + match.Groups["flags"].Value + "]", "Rule Processing");
                        }

                        #endregion
                    }
                    else if (RewriteRuleLine.IsMatch(line))
                    {
                        #region RewriteRule

                        Match match = RewriteRuleLine.Match(line);

                        string module1 = match.Groups["module1"].Value;
                        string module2 = match.Groups["module2"].Value;

                        Type moduleType1 = null;
                        Type moduleType2 = null;

                        // set the types of the first module
                        if (modules.ContainsName(module1))
                        {
                            moduleType1 = modules.GetModule(module1);
                        }

                        // make sure the module is of the right type
                        if (moduleType1 != null && moduleType1.GetInterface("IRule", false) == null)
                        {
                            moduleType1 = null;
                        }

                        // set the types of the second module
                        if (modules.ContainsName(module2))
                        {
                            moduleType2 = modules.GetModule(module2);
                        }

                        // make sure the module is of the right type
                        if (moduleType2 != null && moduleType2.GetInterface("IRuleAction", false) == null)
                        {
                            moduleType2 = null;
                        }

                        try
                        {
                            RegexOptions       patternOptions = Manager.RuleOptions;
                            IRuleFlagProcessor flags;

                            if (match.Groups["flags"] != null)
                            {
                                flags = SplitRuleFlags(match.Groups["flags"].Value);
                            }
                            else
                            {
                                flags = new RuleFlagProcessor();
                            }

                            // check to see if the pattern should ignore the case when testing
                            if (RuleFlagsProcessor.HasNoCase(flags))
                            {
                                patternOptions |= RegexOptions.IgnoreCase;
                            }

                            IRule       rule         = null;
                            IRuleAction substitution = null;
                            Pattern     pattern      = new Pattern(match.Groups["pattern"].Value, patternOptions);

                            // create the first module
                            if (moduleType1 == null)
                            {
                                rule = new DefaultRule();
                            }
                            else
                            {
                                rule = Activator.CreateInstance(moduleType1) as IRule;
                            }

                            // create the second module
                            if (moduleType2 == null)
                            {
                                substitution = new DefaultRuleAction();
                            }
                            else
                            {
                                substitution = Activator.CreateInstance(moduleType2) as IRuleAction;
                            }

                            // initialize the modules
                            substitution.Init(pattern, match.Groups["substitution"].Value);
                            rule.Init(conditions, substitution, flags);

                            // add condition to next rule that shows up
                            rules.Add(rule);

                            // clear conditions for next rule
                            conditions.Clear();
                        }
                        catch (Exception exc)
                        {
                            if (tempLogLevel >= 3)
                            {
                                Manager.Log("RewriteRule: " + exc.Message, "Error");
                            }
                            else
                            {
                                Manager.Log("RewriteRule: " + exc, "Error");
                            }
                        }
                        finally
                        {
                            Manager.LogIf(tempLogLevel >= 3, "RewriteRule: " + match.Groups["pattern"].Value + " " + match.Groups["substitution"].Value + " [" + match.Groups["flags"].Value + "]", "Rule Processing");
                        }

                        #endregion
                    }
                    else if (OutRewriteCondLine.IsMatch(line))
                    {
                        #region OutRewriteCond

                        Match match = OutRewriteCondLine.Match(line);

                        string module1 = match.Groups["module1"].Value;
                        string module2 = match.Groups["module2"].Value;

                        Type moduleType1 = null;
                        Type moduleType2 = null;

                        // set the types of the first module
                        if (modules.ContainsName(module1))
                        {
                            moduleType1 = modules.GetModule(module1);
                        }

                        // make sure the module is of the right type
                        if (moduleType1 != null && moduleType1.GetInterface("ICondition", false) == null)
                        {
                            moduleType1 = null;
                        }

                        // set the types of the second module
                        if (modules.ContainsName(module2))
                        {
                            moduleType2 = modules.GetModule(module2);
                        }

                        // make sure the module is of the right type
                        if (moduleType2 != null && moduleType2.GetInterface("IConditionTestValue", false) == null)
                        {
                            moduleType2 = null;
                        }

                        try
                        {
                            RegexOptions            patternOptions = Manager.RuleOptions;
                            IConditionFlagProcessor flags;

                            if (match.Groups["flags"] != null)
                            {
                                flags = SplitConditionFlags(match.Groups["flags"].Value);
                            }
                            else
                            {
                                flags = new ConditionFlagProcessor();
                            }

                            // check to see if the pattern should ignore the case when testing
                            if (ConditionFlagsProcessor.HasNoCase(flags))
                            {
                                patternOptions |= RegexOptions.IgnoreCase;
                            }

                            string test    = match.Groups["test"].Value;
                            string pattern = match.Groups["pattern"].Value;
                            IConditionTestValue testValue;
                            ICondition          condition;

                            // create the second module
                            if (moduleType2 == null)
                            {
                                testValue = GetConditionTestValue(ref test);
                            }
                            else
                            {
                                testValue = Activator.CreateInstance(moduleType2) as IConditionTestValue;
                            }

                            // create the first module
                            if (moduleType1 == null)
                            {
                                condition = GetCondition(pattern);
                            }
                            else
                            {
                                condition = Activator.CreateInstance(moduleType1) as ICondition;
                            }

                            // initialize the modules
                            testValue.Init(test);
                            condition.Init(new Pattern(pattern, patternOptions), testValue, flags);

                            // add condition to next rule that shows up
                            conditions.Add(condition);
                        }
                        catch (Exception exc)
                        {
                            if (tempLogLevel >= 3)
                            {
                                Manager.Log("OutRewriteCond: " + exc.Message, "Error");
                            }
                            else
                            {
                                Manager.Log("OutRewriteCond: " + exc, "Error");
                            }
                        }
                        finally
                        {
                            Manager.LogIf(tempLogLevel >= 3, "OutRewriteCond: " + match.Groups["test"].Value + " " + match.Groups["pattern"].Value + " [" + match.Groups["flags"].Value + "]", "Rule Processing");
                        }

                        #endregion
                    }
                    else if (OutRewriteRuleLine.IsMatch(line))
                    {
                        #region OutRewriteRule

                        Match match = OutRewriteRuleLine.Match(line);

                        string module1 = match.Groups["module1"].Value;
                        string module2 = match.Groups["module2"].Value;

                        Type moduleType1 = null;
                        Type moduleType2 = null;

                        // set the types of the first module
                        if (modules.ContainsName(module1))
                        {
                            moduleType1 = modules.GetModule(module1);
                        }

                        // make sure the module is of the right type
                        if (moduleType1 != null && moduleType1.GetInterface("IRule", false) == null)
                        {
                            moduleType1 = null;
                        }

                        // set the types of the second module
                        if (modules.ContainsName(module2))
                        {
                            moduleType2 = modules.GetModule(module2);
                        }

                        // make sure the module is of the right type
                        if (moduleType2 != null && moduleType2.GetInterface("IRuleAction", false) == null)
                        {
                            moduleType2 = null;
                        }

                        try
                        {
                            RegexOptions       patternOptions = Manager.RuleOptions;
                            IRuleFlagProcessor flags;

                            if (match.Groups["flags"] != null)
                            {
                                flags = SplitRuleFlags(match.Groups["flags"].Value);
                            }
                            else
                            {
                                flags = new RuleFlagProcessor();
                            }

                            // check to see if the pattern should ignore the case when testing
                            if (RuleFlagsProcessor.HasNoCase(flags))
                            {
                                patternOptions |= RegexOptions.IgnoreCase;
                            }

                            IRule       rule         = null;
                            IRuleAction substitution = null;
                            Pattern     pattern      = new Pattern(match.Groups["pattern"].Value, patternOptions);

                            // create the first module
                            if (moduleType1 == null)
                            {
                                rule = new DefaultRule();
                            }
                            else
                            {
                                rule = Activator.CreateInstance(moduleType1) as IRule;
                            }

                            // create the second module
                            if (moduleType2 == null)
                            {
                                substitution = new DefaultOutputRuleAction();
                            }
                            else
                            {
                                substitution = Activator.CreateInstance(moduleType2) as IRuleAction;
                            }

                            // initialize the modules
                            substitution.Init(pattern, match.Groups["substitution"].Value);
                            rule.Init(conditions, substitution, flags);

                            // add condition to next rule that shows up
                            outputRules.Add(rule);

                            // clear conditions for next rule
                            conditions.Clear();
                        }
                        catch (Exception exc)
                        {
                            if (tempLogLevel >= 3)
                            {
                                Manager.Log("OutRewriteRule: " + exc.Message, "Error");
                            }
                            else
                            {
                                Manager.Log("OutRewriteRule: " + exc, "Error");
                            }
                        }
                        finally
                        {
                            Manager.LogIf(tempLogLevel >= 3, "OutRewriteRule: " + match.Groups["pattern"].Value + " " + match.Groups["substitution"].Value + " [" + match.Groups["flags"].Value + "]", "Rule Processing");
                        }

                        #endregion
                    }
                    else
                    {
                        unknownLines.Add(line);
                    }
                }

                Manager.LogIf(tempLogLevel > 0, "Managed Fusion Rewriter Version: " + Manager.RewriterVersion, "Rule Processing");

                // clear and add new rules
                ClearRules();
                AddRules(rules);
                AddOutputRules(outputRules);

                // try to process any unknown lines
                if (unknownLines.Count > 0)
                {
                    RefreshUnknownLines(ref unknownLines);

                    foreach (var unknownLine in unknownLines)
                    {
                        Manager.LogIf(tempLogLevel >= 4, "Not Understood: " + unknownLine, "Unknown");
                    }
                }


                // set the ruleset defining properties
                VirtualBase        = tempBase;
                LogLocation        = tempLogPath;
                LogLevel           = tempLogLevel;
                EngineEnabled      = tempEngineEnabled;
                Manager.LogPath    = tempLogPath;
                Manager.LogEnabled = tempLogLevel > 0;
            }
        }