using System.Collections.Generic; namespace Plane.Collections { public static class CollectionExtensions { /// /// Calls ICollection.Add internally, but returns the original collection for chain programming. /// /// The item type. /// The original collection. /// The item to add. /// The original collection. public static ICollection AddEx(this ICollection origin, T itemToAdd) { origin.Add(itemToAdd); return origin; } /// /// Add items to the collection. /// /// The item type. /// The original collection. /// The items to add. /// The original collection. public static ICollection AddEx(this ICollection origin, IEnumerable itemsToAdd) { foreach (var item in itemsToAdd) { origin.Add(item); } return origin; } /// /// Calls ICollection.Clear internally, but returns the original collection for chain programming. /// /// The item type. /// The original collection. /// The original collection. public static ICollection ClearEx(this ICollection origin) { origin.Clear(); return origin; } } }