mirror of https://github.com/dahall/Vanara.git
Fixed problem with GetAllTypes extension method
parent
cd8afc3891
commit
6420d47abc
|
@ -314,11 +314,31 @@ namespace System.Linq
|
|||
/// <returns>An <see cref="IEnumerable{T}"/> whose elements are the result of invoking the transform function on each element of <paramref name="source"/>.</returns>
|
||||
public static IEnumerable<TResult> Select<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
|
||||
{
|
||||
if (source == null) throw new ArgumentNullException(nameof(source));
|
||||
if (selector == null) throw new ArgumentNullException(nameof(selector));
|
||||
foreach (var i in source)
|
||||
yield return selector(i);
|
||||
}
|
||||
|
||||
/// <summary>Projects each element of a sequence to an <see cref="IEnumerable{T}"/> and flattens the resulting sequences into one sequence.</summary>
|
||||
/// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
|
||||
/// <typeparam name="TResult">The type of the elements of the sequence returned by <paramref name="selector"/>.</typeparam>
|
||||
/// <param name="source">A sequence of values to project.</param>
|
||||
/// <param name="selector">A transform function to apply to each element.</param>
|
||||
/// <returns>An <see cref="IEnumerable{T}"/> whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.</returns>
|
||||
public static IEnumerable<TResult> SelectMany<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, IEnumerable<TResult>> selector)
|
||||
{
|
||||
if (source == null) throw new ArgumentNullException(nameof(source));
|
||||
if (selector == null) throw new ArgumentNullException(nameof(selector));
|
||||
foreach (TSource element in source)
|
||||
{
|
||||
foreach (TResult subElement in selector(element))
|
||||
{
|
||||
yield return subElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.</summary>
|
||||
/// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
|
||||
/// <param name="source">An <see cref="IEnumerable{T}"/> to return a single element from.</param>
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Vanara.Extensions
|
|||
/// <summary>Gets all loaded types in the <see cref="AppDomain"/>.</summary>
|
||||
/// <param name="appDomain">The application domain.</param>
|
||||
/// <returns>All loaded types.</returns>
|
||||
public static IEnumerable<Type> GetAllTypes(this AppDomain appDomain) => appDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes());
|
||||
public static IEnumerable<Type> GetAllTypes(this AppDomain appDomain) => appDomain.GetAssemblies().SelectMany(a => a.GetTypes());
|
||||
|
||||
/// <summary>Returns an array of custom attributes applied to this member and identified by <typeparamref name="TAttr"/>.</summary>
|
||||
/// <typeparam name="TAttr">The type of attribute to search for. Only attributes that are assignable to this type are returned.</typeparam>
|
||||
|
@ -178,8 +178,8 @@ namespace Vanara.Extensions
|
|||
try { asm = Assembly.LoadFrom(asmRef); } catch { }
|
||||
if (!TryGetType(asm, typeName, ref ret))
|
||||
{
|
||||
foreach (asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||
if (TryGetType(asm, typeName, ref ret)) break;
|
||||
foreach (var asm2 in AppDomain.CurrentDomain.GetAssemblies())
|
||||
if (TryGetType(asm2, typeName, ref ret)) break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue