@@ -32,18 +32,20 @@ public static string GetColumnTitle(this IColumn column, SummaryStyle style)
32
32
}
33
33
}
34
34
35
- public static bool IsNullOrEmpty < T > ( this IReadOnlyCollection < T > value ) => value == null || value . Count == 0 ;
35
+ public static bool IsNullOrEmpty < T > ( this IReadOnlyCollection < T > ? value ) => value == null || value . Count == 0 ;
36
36
public static bool IsEmpty < T > ( this IReadOnlyCollection < T > value ) => value . Count == 0 ;
37
37
public static bool IsEmpty < T > ( this IEnumerable < T > value ) => ! value . Any ( ) ;
38
38
39
+ public static IEnumerable < T > WhereNotNull < T > ( this IEnumerable < T ? > values ) => values . Where ( value => value != null ) . Cast < T > ( ) ;
40
+
39
41
public static void AddRange < T > ( this HashSet < T > hashSet , IEnumerable < T > collection )
40
42
{
41
43
foreach ( var item in collection )
42
44
hashSet . Add ( item ) ;
43
45
}
44
46
45
47
#if NETSTANDARD2_0
46
- public static TValue GetValueOrDefault < TKey , TValue > ( this IDictionary < TKey , TValue > dictionary , TKey key )
48
+ public static TValue ? GetValueOrDefault < TKey , TValue > ( this IDictionary < TKey , TValue > dictionary , TKey key )
47
49
=> dictionary . TryGetValue ( key , out var value ) ? value : default ;
48
50
#endif
49
51
@@ -97,15 +99,17 @@ internal static string DeleteFileIfExists(this string filePath)
97
99
98
100
internal static string EnsureFolderExists ( this string filePath )
99
101
{
100
- string directoryPath = Path . GetDirectoryName ( filePath ) ;
102
+ string ? directoryPath = Path . GetDirectoryName ( filePath ) ;
103
+ if ( directoryPath == null )
104
+ throw new ArgumentException ( $ "Can't get directory path from '{ filePath } '") ;
101
105
102
106
if ( ! Directory . Exists ( directoryPath ) )
103
107
Directory . CreateDirectory ( directoryPath ) ;
104
108
105
109
return filePath ;
106
110
}
107
111
108
- internal static bool IsNotNullButDoesNotExist ( this FileSystemInfo fileInfo )
112
+ internal static bool IsNotNullButDoesNotExist ( this FileSystemInfo ? fileInfo )
109
113
=> fileInfo != null && ! fileInfo . Exists ;
110
114
}
111
115
}
0 commit comments