From 6ac043e3d58a79652258b801d02ce3a7889ac34a Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Thu, 12 Dec 2019 22:21:20 -0600 Subject: [PATCH] Moved NonNull extension method --- IPA.Loader/Utilities/EnumerableExtensions.cs | 30 ++++++++++++++++++++ IPA.Loader/Utilities/Utils.cs | 30 -------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/IPA.Loader/Utilities/EnumerableExtensions.cs b/IPA.Loader/Utilities/EnumerableExtensions.cs index 61ba93a4..f9220e89 100644 --- a/IPA.Loader/Utilities/EnumerableExtensions.cs +++ b/IPA.Loader/Utilities/EnumerableExtensions.cs @@ -41,5 +41,35 @@ namespace IPA.Utilities IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } + + /// + /// LINQ extension method that filters elements out of an enumeration. + /// + /// the type of the enumeration + /// the enumeration to filter + /// a filtered enumerable + public static IEnumerable NonNull(this IEnumerable self) where T : class + => self.Where(o => o != null); + + /// + /// LINQ extension method that filters elements out of an enumeration based on a converter. + /// + /// the type of the enumeration + /// the type to compare to null + /// the enumeration to filter + /// the predicate to select for filtering + /// a filtered enumerable + public static IEnumerable NonNull(this IEnumerable self, Func pred) where T : class where U : class + => self.Where(o => pred(o) != null); + + /// + /// LINQ extension method that filters elements from an enumeration of nullable types. + /// + /// the underlying type of the nullable enumeration + /// the enumeration to filter + /// a filtered enumerable + public static IEnumerable NonNull(this IEnumerable self) where T : struct + => self.Where(o => o != null).Select(o => o.Value); + } } diff --git a/IPA.Loader/Utilities/Utils.cs b/IPA.Loader/Utilities/Utils.cs index bfa153e1..8226d583 100644 --- a/IPA.Loader/Utilities/Utils.cs +++ b/IPA.Loader/Utilities/Utils.cs @@ -189,36 +189,6 @@ namespace IPA.Utilities return cmpVal; } - /// - /// LINQ extension method that filters elements out of an enumeration. - /// - /// the type of the enumeration - /// the enumeration to filter - /// a filtered enumerable - public static IEnumerable NonNull(this IEnumerable self) where T : class - => self.Where(o => o != null); - - /// - /// LINQ extension method that filters elements out of an enumeration based on a converter. - /// - /// the type of the enumeration - /// the type to compare to null - /// the enumeration to filter - /// the predicate to select for filtering - /// a filtered enumerable - public static IEnumerable NonNull(this IEnumerable self, Func pred) where T : class where U : class - => self.Where(o => pred(o) != null); - - /// - /// LINQ extension method that filters elements from an enumeration of nullable types. - /// - /// the underlying type of the nullable enumeration - /// the enumeration to filter - /// a filtered enumerable - public static IEnumerable NonNull(this IEnumerable self) where T : struct - => self.Where(o => o != null).Select(o => o.Value); - - internal static bool HasInterface(this TypeDefinition type, string interfaceFullName) {