/// <summary> /// Adds items to the collection if they are not already present. /// </summary> /// <typeparam name="T">The type of the collection's elements and the items to add.</typeparam> /// <param name="collection">The collection to which the items will be added.</param> /// <param name="items">The items to add to the collection.</param> public static void AddRangeIfNew <T>(this ICollection <T> collection, params T[] items) { collection.AddRangeIf(queriedItem => !collection.Contains(queriedItem), items); }
/// <summary> /// Adds items to the collection if they are not already present. /// </summary> /// <typeparam name="T">The type of the collection's elements and the items to add.</typeparam> /// <param name="collection">The collection to which the items will be added.</param> /// <param name="items">The items to add to the collection.</param> public static void AddRangeIfNew <T>(this ICollection <T> collection, IEnumerable <T> items) { collection.AddRangeIf(queriedItem => !collection.Contains(queriedItem), items); }