/// <summary> /// Compare 2 rule sides per Item /// </summary> /// <param name="s1"></param> /// <param name="s2"></param> /// <param name="index"></param> /// <param name="last"></param> /// <returns></returns> private int CompareRuleSides(RuleSide s1, RuleSide s2, int index, int last) { var itemA = s1.Items.Length > index ? s1.Items[index] : null; var itemB = s2.Items.Length > index ? s2.Items[index] : null; if (itemA == null && itemB == null) { return(last); } else if (itemA == null) { return(-1); } else if (itemB == null) { return(1); } int compare = itemA.CompareTo(itemB); if (compare == 0) { return(CompareRuleSides(s1, s2, index + 1, compare)); } else { return(compare); } }
public int CompareTo(object obj) { RuleSide r2 = obj as RuleSide; if (this.IsEmpty() && r2.IsEmpty()) { return(0); } return(CompareRuleSides(this, r2, 0, 0)); }
public Rule(IEnumerable <String> left, IEnumerable <String> right) { this.Left = new RuleSide(left); this.Right = new RuleSide(right); }