using System.Collections.Generic; using System.Linq; namespace Swan { /// /// This class contains extension methods for types implementing IEnumerable<TSource> /// public static class EnumerableExtensions { /// /// This method returns the Union /// of all non-null parameters. /// /// The type of the elements of the input sequences. /// An IEnumerable<TSource> whose distinct elements forms the first set of the union. /// An IEnumerable<TSource> whose distinct elements forms the second set of the union. /// /// An that contains the elements from non-null input sequences, excluding duplicates. /// public static IEnumerable UnionExcludingNulls(this IEnumerable @this, IEnumerable second) => Enumerable.Union( @this ?? Enumerable.Empty(), second ?? Enumerable.Empty()); /// /// This method returns the Union /// of all non-null parameters. /// /// The type of the elements of the input sequences. /// An IEnumerable<TSource> whose distinct elements forms the first set of the union. /// An IEnumerable<TSource> whose distinct elements forms the second set of the union. /// The IEqualityComparer<TSource> to compare values. /// /// An that contains the elements from non-null input sequences, excluding duplicates. /// public static IEnumerable UnionExcludingNulls(this IEnumerable @this, IEnumerable second, IEqualityComparer comparer) => Enumerable.Union( @this ?? Enumerable.Empty(), second ?? Enumerable.Empty(), comparer); } }