/// <summary> /// Compares the current instance with another object of the same type. /// </summary> public int CompareTo(ViewNode other) { if (other == null) { return(1); } int compareResult = SortOrder.CompareTo(other.SortOrder); if (compareResult != 0) { return(compareResult); } compareResult = ViewID.CompareTo(other.ViewID); if (compareResult != 0) { return(compareResult); } compareResult = string.Compare(Text, other.Text, StringComparison.OrdinalIgnoreCase); if (compareResult != 0) { return(compareResult); } return(string.Compare(Url, other.Url, StringComparison.OrdinalIgnoreCase)); }
/// <summary> /// Сравнить текущий объект с другим объектом такого же типа /// </summary> public int CompareTo(ViewItem other) { int subsWeight1 = Subitems.Count > 0 ? 0 : 1; int subsWeight2 = other.Subitems.Count > 0 ? 0 : 1; int comp1 = subsWeight1.CompareTo(subsWeight2); if (comp1 == 0) { int comp2 = ViewID.CompareTo(other.ViewID); return(comp2 == 0 ? Text.CompareTo(other.Text) : comp2); } else { return(comp1); } }