From 65eaa912cf4f9147809b46ccefa83290825c2fbb Mon Sep 17 00:00:00 2001 From: Tyrrrz Date: Thu, 8 Apr 2021 20:53:48 +0300 Subject: [PATCH] Refactor --- CliFx/Schema/BindablePropertyDescriptor.cs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/CliFx/Schema/BindablePropertyDescriptor.cs b/CliFx/Schema/BindablePropertyDescriptor.cs index 0f9b804..4aa7447 100644 --- a/CliFx/Schema/BindablePropertyDescriptor.cs +++ b/CliFx/Schema/BindablePropertyDescriptor.cs @@ -21,17 +21,10 @@ namespace CliFx.Schema public IReadOnlyList GetValidValues() { - Type typeToCheck = Type; - foreach (var inf in typeToCheck.GetInterfaces()) - { - if (inf.IsGenericType && inf.GetGenericTypeDefinition() == typeof(IEnumerable<>)) - { - typeToCheck = inf.GenericTypeArguments[0]; - break; - } - } - - var underlyingType = typeToCheck.TryGetNullableUnderlyingType() ?? typeToCheck; + var underlyingType = + Type.TryGetNullableUnderlyingType() ?? + Type.TryGetEnumerableUnderlyingType() ?? + Type; // We can only get valid values for enums if (underlyingType.IsEnum)