mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-09 17:03:08 +00:00
Support for boolean uniform-args
This commit is contained in:
parent
cccf9e426c
commit
76dfd7a86c
@ -194,12 +194,21 @@ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool AssignBool(T result, PropertyInfo uniformProperty, object value)
|
||||
{
|
||||
var s = value.ToString()!.ToLowerInvariant();
|
||||
var isTrue = (s == "1" || s == "true");
|
||||
uniformProperty.SetValue(result, isTrue);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool AssignEnum(T result, PropertyInfo uniformProperty, object value)
|
||||
{
|
||||
var s = value.ToString();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user