support for bool in argsuniform

This commit is contained in:
benbierens 2023-06-30 09:14:54 +02:00
parent 0d4960f3ff
commit 0caa53bf8c
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
1 changed files with 10 additions and 0 deletions

View File

@ -203,6 +203,7 @@ namespace ArgsUniform
{
if (uniformProperty.PropertyType == typeof(int?)) return AssignOptionalInt(result, uniformProperty, value);
if (uniformProperty.PropertyType.IsEnum) return AssignEnum(result, uniformProperty, value);
if (uniformProperty.PropertyType == typeof(bool)) return AssignBool(result, uniformProperty, value);
throw new NotSupportedException();
}
@ -230,6 +231,15 @@ namespace ArgsUniform
return false;
}
private static bool AssignBool(T result, PropertyInfo uniformProperty, object value)
{
if (value != null)
{
uniformProperty.SetValue(result, true);
}
return true;
}
private string? GetFromArgs(string key)
{
var argKey = $"--{key}=";