@@ -18,6 +18,18 @@ public static void Add<T>(this ICollection<T> collection, IEnumerable<T> items)
18
18
collection . Add ( item ) ;
19
19
}
20
20
21
+ public static ReadOnlyCollection < T > AsReadOnly < T > ( this ICollection < T > collection )
22
+ {
23
+ Assert . IsNotNull ( collection , nameof ( collection ) ) ;
24
+ return new ReadOnlyCollection < T > ( collection . ToList ( ) ) ;
25
+ }
26
+
27
+ public static ICollection < TResult > Cast < TResult > ( this ICollection source )
28
+ {
29
+ ICollection < TResult > collection = source != null ? new CastedCollection < TResult > ( source ) : null ;
30
+ return collection ;
31
+ }
32
+
21
33
public static bool IsNullOrEmpty ( this ICollection collection )
22
34
{
23
35
var isNullOrEmpty = collection == null || collection . Count == 0 ;
@@ -30,6 +42,8 @@ public static bool IsNullOrEmpty<T>(this ICollection<T> collection)
30
42
return isNullOrEmpty ;
31
43
}
32
44
45
+ public static bool IsNullOrAny < T > ( this ICollection < T > source ) => source != null && source . Count > 0 ;
46
+
33
47
public static int Remove < T > ( this ICollection < T > collection , IEnumerable < T > items )
34
48
{
35
49
Assert . IsTrue ( collection != null || items == null ) ;
@@ -47,20 +61,6 @@ public static int Remove<T>(this ICollection<T> collection, IEnumerable<T> items
47
61
return count ;
48
62
}
49
63
50
- public static ReadOnlyCollection < T > AsReadOnly < T > ( this ICollection < T > collection )
51
- {
52
- Assert . IsNotNull ( collection , nameof ( collection ) ) ;
53
- return new ReadOnlyCollection < T > ( collection . ToList ( ) ) ;
54
- }
55
-
56
- public static ICollection < TResult > Cast < TResult > ( this ICollection source )
57
- {
58
- ICollection < TResult > collection = source != null ? new CastedCollection < TResult > ( source ) : null ;
59
- return collection ;
60
- }
61
-
62
- public static bool IsNullOrAny < T > ( this ICollection < T > source ) => source != null && source . Count > 0 ;
63
-
64
64
public static T [ ] ToArray < T > ( ICollection < T > source )
65
65
{
66
66
Assert . IsNotNull ( source , nameof ( source ) ) ;
0 commit comments