From 79ad7b845279f0952f0ac9208bbeaac7c62a6110 Mon Sep 17 00:00:00 2001 From: David Hall Date: Sat, 16 Nov 2019 15:47:02 -0700 Subject: [PATCH] Added CanGet method to pull when enum is not found --- Core/InteropServices/CorrespondingTypeAttribute.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Core/InteropServices/CorrespondingTypeAttribute.cs b/Core/InteropServices/CorrespondingTypeAttribute.cs index d4c12e80..66a6b926 100644 --- a/Core/InteropServices/CorrespondingTypeAttribute.cs +++ b/Core/InteropServices/CorrespondingTypeAttribute.cs @@ -101,6 +101,15 @@ namespace Vanara.InteropServices return false; } + /// Determines whether an enum value exists that supports a corresponding type of . + /// The corresponding type to look for. + /// The type of the enum. + /// If not , the enumeration value to check. + /// The value of type that has the corresponding type . + /// if this instance can get the specified value; otherwise, . + public static bool CanGet(TEnum? input, out TEnum value) where TEnum : struct, System.Enum => + input.HasValue ? CanGet(value = input.Value, typeof(T)) : CanGet(out value); + /// Determines whether this instance can set the type for the specified enum value or class. /// The enumeration value or class instance. /// The type supplied by the user to validate.