tests/Kingdom.OrTools.Sat.Parameters.Tests/Extensions/TypeExtensionMethods.cs
/// <summary>
/// Returns the <see cref="IEnumerable{T}"/> of <typeparamref name="TUnderlying"/>
/// values. Import inherent or implied verification is performed internally.
/// </summary>
/// <typeparam name="TUnderlying"></typeparam>
/// <param name="enumType"></param>
/// <returns></returns>
Returns the  of
values. Import inherent or implied verification is performed internally.
Returns the of values . Import inherent or implied verification is performed internally .
public static IEnumerable<TUnderlying> GetEnumValues<TUnderlying>(this Type enumType)
            where TUnderlying : struct, IComparable
        {
            var underlyingType = typeof(TUnderlying);
            enumType.GetEnumUnderlyingType().AssertNotNull().AssertEqual(underlyingType);
            TUnderlying AsUnderlying(object value) => (TUnderlying) Convert.ChangeType(value, underlyingType);
            foreach (var x in enumType.PrivateGetEnumValues().AssertNotNull().AssertNotEmpty().Select(AsUnderlying))
            {
                yield return x;
            }
        }
public static IEnumerable < TUnderlying > GetEnumValues < TUnderlying > ( this Type enumType ) where TUnderlying : struct , IComparable { var underlyingType = typeof ( TUnderlying ) ; enumType . GetEnumUnderlyingType ( ) . AssertNotNull ( ) . AssertEqual ( underlyingType ) ; TUnderlying AsUnderlying ( object value ) => ( TUnderlying ) Convert . ChangeType ( value , underlyingType ) ; foreach ( var x in enumType . PrivateGetEnumValues ( ) . AssertNotNull ( ) . AssertNotEmpty ( ) . Select ( AsUnderlying ) ) { yield return x ; } }
Returns the  of
values.
Returns the of values .
None
Type
this
enumType
None
typeparam
None