src/Mimp.SeeSharper.Reflection/TypeExtensions.Generic.cs
/// <summary>
/// Return all inherit types of <paramref name="genericTypeDefinition"/>.
/// </summary>
/// <param name="type"></param>
/// <param name="genericTypeDefinition"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentException">If <paramref name="genericTypeDefinition"/> isn't a generic type definition.</exception>
Return all inherit types of .
Return all inherit types of .
public static IEnumerable<Type> GetGenericTypes(this Type type, Type genericTypeDefinition)
        {
            if (type is null)
                throw new ArgumentNullException(nameof(type));
            if (genericTypeDefinition is null)
                throw new ArgumentNullException(nameof(genericTypeDefinition));
            if (!genericTypeDefinition.IsGenericTypeDefinition)
                throw new ArgumentException($"{genericTypeDefinition} isn't a generic type definition.", nameof(genericTypeDefinition));
            foreach (var types in type.GetAllGenericArguments(genericTypeDefinition))
                yield return types.Any() ? genericTypeDefinition.MakeGenericType(types.ToArray()) : genericTypeDefinition;
        }
public static IEnumerable < Type > GetGenericTypes ( this Type type , Type genericTypeDefinition ) { if ( type is null ) throw new ArgumentNullException ( nameof ( type ) ) ; if ( genericTypeDefinition is null ) throw new ArgumentNullException ( nameof ( genericTypeDefinition ) ) ; if ( ! genericTypeDefinition . IsGenericTypeDefinition ) throw new ArgumentException ( $" { genericTypeDefinition }  isn't a generic type definition. " , nameof ( genericTypeDefinition ) ) ; foreach ( var types in type . GetAllGenericArguments ( genericTypeDefinition ) ) yield return types . Any ( ) ? genericTypeDefinition . MakeGenericType ( types . ToArray ( ) ) : genericTypeDefinition ; }
Return all inherit types of .
Return all inherit types of .
None
None
If  isn't a generic type definition.
If isn ' t a generic type definition .
Type
this
genericTypeDefinition
Type
None
type
None