From 0caa53bf8ca72fee1f4f5c08828e74ca831912a7 Mon Sep 17 00:00:00 2001 From: benbierens Date: Fri, 30 Jun 2023 09:14:54 +0200 Subject: [PATCH] support for bool in argsuniform --- ArgsUniform/ArgsUniform.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ArgsUniform/ArgsUniform.cs b/ArgsUniform/ArgsUniform.cs index 88e539a..1cb0792 100644 --- a/ArgsUniform/ArgsUniform.cs +++ b/ArgsUniform/ArgsUniform.cs @@ -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}=";