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…
Reference in New Issue