/// <summary> /// Removes the last instance of the elements from this object. /// </summary> /// <typeparam name="TElement">The type of the elements in the collection.</typeparam> /// <param name="collection">This collection.</param> /// <param name="elements">The elements to remove.</param> public static void RemoveLast <TElement>(this IRemove <TElement> collection, Collections.Generic.IEnumerable <TElement>?elements) { if (elements is not null) { foreach (TElement element in elements) { collection.RemoveLast(element); } } }
/// <summary> /// Prepends the elements onto this object, one by one. /// </summary> /// <typeparam name="TElement">The type of the elements in the collection.</typeparam> /// <param name="collection">This collection.</param> /// <param name="elements">The elements to prepend.</param> public static void Prepend <TElement>(this IPrepend <TElement> collection, Collections.Generic.IEnumerable <TElement>?elements) { if (elements is not null) { foreach (TElement element in elements) { collection.Prepend(element); } } }
public void FieldsAreFound(Type type, FieldSource source, FieldCollection expectedFields) { var fields = type.FindFields(source); Assert.Equal(expectedFields, fields); }
public static bool SafeAny<T>(this IEnumerable<T> collection) { return collection?.Any() ?? false; }