Added CanGet method to pull when enum is not found

pull/83/head
David Hall 2019-11-16 15:47:02 -07:00
parent 2eab8af7eb
commit 79ad7b8452
1 changed files with 9 additions and 0 deletions

View File

@ -101,6 +101,15 @@ namespace Vanara.InteropServices
return false;
}
/// <summary>Determines whether an enum value exists that supports a corresponding type of <typeparamref name="T"/>.</summary>
/// <typeparam name="T">The corresponding type to look for.</typeparam>
/// <typeparam name="TEnum">The type of the enum.</typeparam>
/// <param name="input">If not <see langword="null"/>, the enumeration value to check.</param>
/// <param name="value">The value of type <typeparamref name="TEnum"/> that has the corresponding type <typeparamref name="T"/>.</param>
/// <returns><see langword="true"/> if this instance can get the specified value; otherwise, <see langword="false"/>.</returns>
public static bool CanGet<T, TEnum>(TEnum? input, out TEnum value) where TEnum : struct, System.Enum =>
input.HasValue ? CanGet(value = input.Value, typeof(T)) : CanGet<T, TEnum>(out value);
/// <summary>Determines whether this instance can set the type for the specified enum value or class.</summary>
/// <param name="value">The enumeration value or class instance.</param>
/// <param name="typeRef">The type supplied by the user to validate.</param>