/// <summary> /// Splits the rule flags. /// </summary> /// <param name="flags">The flags.</param> /// <returns></returns> protected IRuleFlagProcessor SplitRuleFlags(string flags) { RuleFlagProcessor dictionary = new RuleFlagProcessor(); List <string> temporaryHolding = new List <string>(); dictionary.BeginAdd(); foreach (string flag in flags.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { string temp = flag; if (flag.Contains("\"") || temporaryHolding.Count > 0) { temporaryHolding.Add(flag.Replace("\"", String.Empty)); if (flag.Contains("\"") && temporaryHolding.Count > 1) { temp = String.Join(",", temporaryHolding.ToArray()); temporaryHolding.Clear(); } else { continue; } } IRuleFlag ruleFlag = AddRuleFlag(temp); if (ruleFlag != null) { dictionary.Add(ruleFlag); } } dictionary.EndAdd(); return(dictionary); }
/// <summary> /// Performs a comparison between rules inorder to sort them /// </summary> /// <param name="a">Rule X</param> /// <param name="b">Rule Y</param> /// <returns></returns> private int Comparison(IRuleFlag x, IRuleFlag y) { bool xLast = x is LastFlag; bool yLast = y is LastFlag; bool xExit = x is ProxyFlag || x is RedirectFlag; bool yExit = y is ProxyFlag || y is RedirectFlag; bool isXSpecial = xLast || xExit; bool isYSpecial = yLast || yExit; // neither are a special case if (!isXSpecial && !isYSpecial) return 0; // y is a special case else if (!isXSpecial && isYSpecial) return -1; // x is a special case else if (isXSpecial && !isYSpecial) return 1; // both special case, x is Last and y is Exit else if (xLast && yExit) return 1; // both special case, y is Last and x is Exit else if (xExit && yLast) return -1; // they are equal else return 0; }
/// <summary> /// Performs a comparison between rules inorder to sort them /// </summary> /// <param name="a">Rule X</param> /// <param name="b">Rule Y</param> /// <returns></returns> private int Comparison(IRuleFlag x, IRuleFlag y) { bool xLast = x is LastFlag; bool yLast = y is LastFlag; bool xExit = x is ProxyFlag || x is RedirectFlag; bool yExit = y is ProxyFlag || y is RedirectFlag; bool isXSpecial = xLast || xExit; bool isYSpecial = yLast || yExit; // neither are a special case if (!isXSpecial && !isYSpecial) { return(0); } // y is a special case else if (!isXSpecial && isYSpecial) { return(-1); } // x is a special case else if (isXSpecial && !isYSpecial) { return(1); } // both special case, x is Last and y is Exit else if (xLast && yExit) { return(1); } // both special case, y is Last and x is Exit else if (xExit && yLast) { return(-1); } // they are equal else { return(0); } }
/// <summary> /// Adds the specified flag. /// </summary> /// <param name="flag">The flag.</param> public void Add(IRuleFlag flag) { _flags.Add(flag); }