private static void TranslateRuleEngine(RewriteEntry result, Parser.RawEntry entry)
 {
     Parser.RawRuleEngine rawRuleEngine = (Parser.RawRuleEngine)entry;
     if (string.Equals(rawRuleEngine.Value, "On", StringComparison.OrdinalIgnoreCase))
     {
         result.Enabled = true;
     }
     else if (string.Equals(rawRuleEngine.Value, "Off", StringComparison.OrdinalIgnoreCase))
     {
         result.Enabled = false;
     }
     result.Raw = rawRuleEngine;
 }
Beispiel #2
0
 internal RewriteEntry(Parser.RawEntry rawEntry, bool isServerLevel) : base(rawEntry)
 {
     _isServerLevel = isServerLevel;
 }
 internal RuleEntry(Parser.RawEntry rawEntry) : base(rawEntry)
 {
 }
        public static RewriteEntry Translate(string input, bool isServerLevel, int baseNumber)
        {
            Parser parser = new Parser(input);
            IList <Parser.RawEntry> list         = parser.Parse();
            RewriteEntry            rewriteEntry = new RewriteEntry(null, isServerLevel);
            List <CommentEntry>     list2        = null;
            bool flag = false;
            List <ConditionEntry> list3 = null;

            for (int i = 0; i < list.Count; i++)
            {
                Parser.RawEntry rawEntry = list[i];
                if (rawEntry is Parser.RawCondition)
                {
                    if (list3 == null)
                    {
                        list3 = new List <ConditionEntry>();
                    }
                    ConditionEntry conditionEntry = ConditionLogic.Create((Parser.RawCondition)rawEntry);
                    if (list2 != null)
                    {
                        conditionEntry.Comments.AddRange(list2);
                        list2 = null;
                    }
                    list3.Add(conditionEntry);
                }
                else if (rawEntry is Parser.RawRule)
                {
                    RuleEntry ruleEntry = RuleLogic.Create(rewriteEntry, (Parser.RawRule)rawEntry, isServerLevel);
                    ruleEntry.Name = string.Format(CultureInfo.InvariantCulture, "Imported Rule {0}", rewriteEntry.Rules.Count + baseNumber + 1);
                    if (list3 != null)
                    {
                        AddConditionsToRule(list3, ruleEntry);
                    }
                    list3 = null;
                    if (flag || ruleEntry.IsChained)
                    {
                        ruleEntry.ErrorInfo = new ErrorInfo("This rule was not converted because it is chained to other rules.");
                        flag = ruleEntry.IsChained;
                    }
                    if (list2 != null)
                    {
                        ruleEntry.Comments.AddRange(list2);
                        list2 = null;
                    }
                    rewriteEntry.Rules.Add(ruleEntry);
                }
                else if (rawEntry is Parser.RawComment)
                {
                    if (list2 == null)
                    {
                        list2 = new List <CommentEntry>();
                    }
                    list2.Add(new CommentEntry((Parser.RawComment)rawEntry));
                }
                else if (rawEntry is Parser.RawRuleEngine)
                {
                    TranslateRuleEngine(rewriteEntry, rawEntry);
                }
                else if (rawEntry is Parser.UnsupportedDirective)
                {
                    rewriteEntry.UnsupportedDirectives.Add(new UnsupportedDirectiveEntry((Parser.UnsupportedDirective)rawEntry));
                }
            }
            return(rewriteEntry);
        }
Beispiel #5
0
 internal Entry(Parser.RawEntry rawEntry)
 {
     _entryNodeFactory = new EntryTreeNodeFactory();
     Raw = rawEntry;
 }
 public ConditionEntry(Parser.RawEntry rawEntry) : base(rawEntry)
 {
 }