You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/MADE.Collections/CollectionExtensions.cs
+36-1Lines changed: 36 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,8 @@ public static class CollectionExtensions
19
19
/// <param name="item">The item to add.</param>
20
20
/// <param name="condition">The condition required to add the item.</param>
21
21
/// <typeparam name="T">The type of item within the collection.</typeparam>
22
+
/// <exception cref="ArgumentNullException">Thrown if the <paramref name="collection"/> or <paramref name="condition"/> is <see langword="null"/>.</exception>
23
+
/// <exception cref="Exception">Potentially thrown by the delegate callback.</exception>
@@ -37,6 +39,33 @@ public static void AddIf<T>(this IList<T> collection, T item, Func<bool> conditi
37
39
}
38
40
}
39
41
42
+
/// <summary>
43
+
/// Removes the specified item from the collection based on the specified condition being true.
44
+
/// </summary>
45
+
/// <param name="collection">The collection to remove the item from.</param>
46
+
/// <param name="item">The item to remove.</param>
47
+
/// <param name="condition">The condition required to remove the item.</param>
48
+
/// <typeparam name="T">The type of item within the collection.</typeparam>
49
+
/// <exception cref="ArgumentNullException">Thrown if the <paramref name="collection"/> or <paramref name="condition"/> is <see langword="null"/>.</exception>
50
+
/// <exception cref="Exception">Potentially thrown by the delegate callback.</exception>
@@ -146,6 +175,8 @@ public static void AddRange<T>(this ICollection<T> collection, IEnumerable<T> it
146
175
/// <param name="itemsToAdd">The items to add.</param>
147
176
/// <param name="condition">The condition required to add the items.</param>
148
177
/// <typeparam name="T">The type of item within the collection.</typeparam>
178
+
/// <exception cref="ArgumentNullException">Thrown if the <paramref name="collection"/>, <paramref name="itemsToAdd"/> or <paramref name="condition"/> is <see langword="null"/>.</exception>
179
+
/// <exception cref="Exception">Potentially thrown by the delegate callback.</exception>
/// <param name="itemsToRemove">The items to remove.</param>
204
235
/// <param name="condition">The condition required to remove the items.</param>
205
236
/// <typeparam name="T">The type of item within the collection.</typeparam>
237
+
/// <exception cref="ArgumentNullException">Thrown if the <paramref name="collection"/>, <paramref name="itemsToRemove"/> or <paramref name="condition"/> is <see langword="null"/>.</exception>
238
+
/// <exception cref="Exception">Potentially thrown by the delegate callback.</exception>
206
239
publicstaticvoidRemoveRangeIf<T>(
207
240
thisICollection<T>collection,
208
241
IEnumerable<T>itemsToRemove,
@@ -290,6 +323,7 @@ public static IEnumerable<T> TakeFrom<T>(this List<T> list, int startingIndex, i
290
323
/// <param name="action">
291
324
/// The action to perform.
292
325
/// </param>
326
+
/// <exception cref="Exception">Potentially thrown by the delegate callback.</exception>
@@ -333,6 +367,7 @@ public static int InsertAtPotentialIndex<T>(this IList<T> source, T value, Func<
333
367
/// <param name="predicate">The action to run to determine the position of the item based on the provided <paramref name="value"/> and an item in the collection.</param>
334
368
/// <typeparam name="T">The type of items in the collection.</typeparam>
335
369
/// <returns>The potential index of the item.</returns>
370
+
/// <exception cref="Exception">Potentially thrown by the delegate callback.</exception>
0 commit comments