Browse Source

Moved NonNull extension method

4.0.0-beta
Anairkoen Schno 4 years ago
parent
commit
5af25104c4
2 changed files with 30 additions and 30 deletions
  1. +30
    -0
      IPA.Loader/Utilities/EnumerableExtensions.cs
  2. +0
    -30
      IPA.Loader/Utilities/Utils.cs

+ 30
- 0
IPA.Loader/Utilities/EnumerableExtensions.cs View File

@ -41,5 +41,35 @@ namespace IPA.Utilities
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
/// <summary>
/// LINQ extension method that filters <see langword="null"/> elements out of an enumeration.
/// </summary>
/// <typeparam name="T">the type of the enumeration</typeparam>
/// <param name="self">the enumeration to filter</param>
/// <returns>a filtered enumerable</returns>
public static IEnumerable<T> NonNull<T>(this IEnumerable<T> self) where T : class
=> self.Where(o => o != null);
/// <summary>
/// LINQ extension method that filters <see langword="null"/> elements out of an enumeration based on a converter.
/// </summary>
/// <typeparam name="T">the type of the enumeration</typeparam>
/// <typeparam name="U">the type to compare to null</typeparam>
/// <param name="self">the enumeration to filter</param>
/// <param name="pred">the predicate to select for filtering</param>
/// <returns>a filtered enumerable</returns>
public static IEnumerable<T> NonNull<T, U>(this IEnumerable<T> self, Func<T, U> pred) where T : class where U : class
=> self.Where(o => pred(o) != null);
/// <summary>
/// LINQ extension method that filters <see langword="null"/> elements from an enumeration of nullable types.
/// </summary>
/// <typeparam name="T">the underlying type of the nullable enumeration</typeparam>
/// <param name="self">the enumeration to filter</param>
/// <returns>a filtered enumerable</returns>
public static IEnumerable<T> NonNull<T>(this IEnumerable<T?> self) where T : struct
=> self.Where(o => o != null).Select(o => o.Value);
}
}

+ 0
- 30
IPA.Loader/Utilities/Utils.cs View File

@ -189,36 +189,6 @@ namespace IPA.Utilities
return cmpVal;
}
/// <summary>
/// LINQ extension method that filters <see langword="null"/> elements out of an enumeration.
/// </summary>
/// <typeparam name="T">the type of the enumeration</typeparam>
/// <param name="self">the enumeration to filter</param>
/// <returns>a filtered enumerable</returns>
public static IEnumerable<T> NonNull<T>(this IEnumerable<T> self) where T : class
=> self.Where(o => o != null);
/// <summary>
/// LINQ extension method that filters <see langword="null"/> elements out of an enumeration based on a converter.
/// </summary>
/// <typeparam name="T">the type of the enumeration</typeparam>
/// <typeparam name="U">the type to compare to null</typeparam>
/// <param name="self">the enumeration to filter</param>
/// <param name="pred">the predicate to select for filtering</param>
/// <returns>a filtered enumerable</returns>
public static IEnumerable<T> NonNull<T, U>(this IEnumerable<T> self, Func<T, U> pred) where T : class where U : class
=> self.Where(o => pred(o) != null);
/// <summary>
/// LINQ extension method that filters <see langword="null"/> elements from an enumeration of nullable types.
/// </summary>
/// <typeparam name="T">the underlying type of the nullable enumeration</typeparam>
/// <param name="self">the enumeration to filter</param>
/// <returns>a filtered enumerable</returns>
public static IEnumerable<T> NonNull<T>(this IEnumerable<T?> self) where T : struct
=> self.Where(o => o != null).Select(o => o.Value);
internal static bool HasInterface(this TypeDefinition type, string interfaceFullName)
{


Loading…
Cancel
Save