public override int Compare(char[] x, char[] y) { if (x == null || y == null) return Default.Compare(x, y); var lengthComp = x.Length.CompareTo(y.Length); return lengthComp != 0 ? lengthComp : StringComparer.Ordinal.Compare(new string(x), new string(y)); }
public override Int32 Compare(TKey x, TKey y) { if (x == null || y == null) { return(0); } return(x.Equals(y) ? 1 : Default.Compare(x, y)); }
/// <summary> /// Is the given left hand side value less than or equal to the given right hand side value? /// </summary> /// <param name="lhs">Left hand side.</param> /// <param name="rhs">Right hand side.</param> /// <param name="context">Gets the originator of that issued the state.</param> /// <typeparam name="TValue">Comparable type.</typeparam> /// <returns>True if the left hand side value is less than or equal to the right hand side value; otherwise, false.</returns> internal static Assertion IsLessThanOrEqualTo <TValue>(TValue lhs, TValue rhs, StackTraceContext context) where TValue : IComparable { return(Default.Compare(lhs, rhs) <= 0 ? new Assertion(true, nameof(IsLessThanOrEqualTo), $"{ToString(lhs)} is less than or equal to {ToString(rhs)}", context) : new Assertion(false, nameof(IsLessThanOrEqualTo), $"{ToString(lhs)} is not less than nor equal to {ToString(rhs)}", context)); }
/// <summary> /// Is the given left hand side value greater than the given right hand side value? /// </summary> /// <param name="lhs">Left hand side.</param> /// <param name="rhs">Right hand side.</param> /// <param name="context">Gets the originator of that issued the state.</param> /// <typeparam name="TValue">Comparable type.</typeparam> /// <returns>True if the left hand side value is greater than the right hand side value; otherwise, false.</returns> internal static Assertion IsGreaterThan <TValue>(TValue lhs, TValue rhs, StackTraceContext context) where TValue : IComparable { return(Default.Compare(lhs, rhs) > 0 ? new Assertion(true, nameof(IsGreaterThan), $"{ToString(lhs)} is greater than {ToString(rhs)}", context) : new Assertion(false, nameof(IsGreaterThan), $"{ToString(lhs)} is not greater than {ToString(rhs)}", context)); }