-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Critical-Impact/api11
Api11
- Loading branch information
Showing
73 changed files
with
35,328 additions
and
15,299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/LuminaSupplemental.Excel/Extensions/EnumerableExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace LuminaSupplemental.Excel.Extensions; | ||
|
||
public static class EnumerableExtensions | ||
{ | ||
public static T? FirstOrNull<T>(this IEnumerable<T> source) where T : struct | ||
{ | ||
return source.Cast<T?>().FirstOrDefault(); | ||
} | ||
|
||
public static T? FirstOrNull<T>(this IEnumerable<T> source, Func<T, bool> predicate) where T : struct | ||
{ | ||
ArgumentNullException.ThrowIfNull(source); | ||
ArgumentNullException.ThrowIfNull(predicate); | ||
return source.Where(predicate).Cast<T?>().FirstOrDefault(); | ||
} | ||
} |
Oops, something went wrong.