public bool Equals(StringLines other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(WithLines(() => other.WithLines(() => { if (other == null) { return _lines.Count == 0; } if (other._lines.Count != _lines.Count) { return false; } return other._lines.Zip(_lines, (a, b) => new { X = a, Y = b }).TakeWhile(a => a.X == a.Y).Count() == _lines.Count; }))); }
public int CompareTo(StringLines other) { if (other == null) { return(1); } if (ReferenceEquals(this, other)) { return(0); } return(WithLines(() => other.WithLines(() => { return _lines.Zip(other._lines, (a, b) => (a == null) ? ((b == null) ? 0 : 1) : ((b == null) ? -1 : a.CompareTo(b))) .SkipWhile(i => i == 0).DefaultIfEmpty(_lines.Count.CompareTo(other._lines.Count)).First(); }))); }