mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Refactor
This commit is contained in:
@@ -21,17 +21,10 @@ namespace CliFx.Schema
|
|||||||
|
|
||||||
public IReadOnlyList<object?> GetValidValues()
|
public IReadOnlyList<object?> GetValidValues()
|
||||||
{
|
{
|
||||||
Type typeToCheck = Type;
|
var underlyingType =
|
||||||
foreach (var inf in typeToCheck.GetInterfaces())
|
Type.TryGetNullableUnderlyingType() ??
|
||||||
{
|
Type.TryGetEnumerableUnderlyingType() ??
|
||||||
if (inf.IsGenericType && inf.GetGenericTypeDefinition() == typeof(IEnumerable<>))
|
Type;
|
||||||
{
|
|
||||||
typeToCheck = inf.GenericTypeArguments[0];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var underlyingType = typeToCheck.TryGetNullableUnderlyingType() ?? typeToCheck;
|
|
||||||
|
|
||||||
// We can only get valid values for enums
|
// We can only get valid values for enums
|
||||||
if (underlyingType.IsEnum)
|
if (underlyingType.IsEnum)
|
||||||
|
|||||||
Reference in New Issue
Block a user