public int CompareTo(ISupportSortSearchValue other, ComparisonRange range) { if (other == null) { throw new ArgumentException("Value to be compared to cannot be null"); } var otherValue = other as DateTimeSearchValue; if (otherValue == null) { throw new ArgumentException($"Value to be compared should be of type {typeof(DateTimeSearchValue)}"); } switch (range) { case ComparisonRange.Min: return(DateTimeOffset.Compare(Start, otherValue.Start)); case ComparisonRange.Max: return(DateTimeOffset.Compare(End, otherValue.End)); default: throw new ArgumentOutOfRangeException(nameof(range)); } }
/// <inheritdoc /> public int CompareTo(ISupportSortSearchValue supportSortSearchValue, ComparisonRange range) { if (supportSortSearchValue == null) { throw new ArgumentException("Value to be compared to cannot be null"); } var otherValue = supportSortSearchValue as StringSearchValue; if (otherValue == null) { throw new ArgumentException($"Value to be compared should be of type {typeof(StringSearchValue)}"); } return(string.Compare(ToString(), otherValue.ToString(), CultureInfo.InvariantCulture, CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase)); }
/// <inheritdoc /> public int CompareTo(ISupportSortSearchValue other, ComparisonRange range) { if (other == null) { throw new ArgumentException("Value to be compared to cannot be null"); } var otherValue = other as StringSearchValue; if (otherValue == null) { throw new ArgumentException($"Value to be compared should be of type {typeof(StringSearchValue)}"); } // We want to do a case and accent insensitive comparison here. // This is to be in-line with the collation used in our SQL tables for the StringSearchParam values #pragma warning disable CA1309 return(string.Compare(ToString(), otherValue.ToString(), CultureInfo.InvariantCulture, CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase)); #pragma warning restore CA1309 }