/// <summary> /// Converts collection to comparable collection with equals/hashCode/toString implementations. /// </summary> /// <typeparam name="T">Type of collection</typeparam> /// <param name="source">this</param> /// <returns>Comparable collection</returns> public static IEnumerable <T> ToComparable <T>(this IEnumerable <T> source) { Preconditions.IsNotNull(source, () => new ArgumentNullException("source")); if (source is IList <T> ) { return(ComparableList <T> .Of((IList <T>) source)); } if (source is ISet <T> ) { return(ComparableSet <T> .Of((ISet <T>) source)); } if (source is ICollection <T> ) { return(ComparableCollection <T> .Of((ICollection <T>) source)); } return(ComparableEnumerable <T> .Of(source)); }
/// <summary> /// Converts collection to comparable collection with equals/hashCode/toString implementations. /// </summary> /// <typeparam name="T">Type of collection</typeparam> /// <param name="source">this</param> /// <returns>Comparable collection</returns> public static ISet <T> ToComparable <T>(this ISet <T> source) { Preconditions.IsNotNull(source, () => new ArgumentNullException("source")); return(ComparableSet <T> .Of(source)); }