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 == typeof(int?)) return AssignOptionalInt(result, uniformProperty, value);
|
||||||
if (uniformProperty.PropertyType.IsEnum) return AssignEnum(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();
|
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)
|
private static bool AssignEnum(T result, PropertyInfo uniformProperty, object value)
|
||||||
{
|
{
|
||||||
var s = value.ToString();
|
var s = value.ToString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user