From a79b0b20e576fde74067614c48398586e7eeb958 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 5 Nov 2021 08:24:56 -0500 Subject: bump dependencies --- .../CommandLineConfigurationSource.cs | 53 ++++++++++------------ 1 file changed, 25 insertions(+), 28 deletions(-) (limited to 'src/slskd/Common/Configuration/CommandLineConfigurationSource.cs') diff --git a/src/slskd/Common/Configuration/CommandLineConfigurationSource.cs b/src/slskd/Common/Configuration/CommandLineConfigurationSource.cs index 0436c922..96d8d623 100644 --- a/src/slskd/Common/Configuration/CommandLineConfigurationSource.cs +++ b/src/slskd/Common/Configuration/CommandLineConfigurationSource.cs @@ -111,45 +111,42 @@ namespace slskd.Configuration var longName = (string)attribute.ConstructorArguments[1].Value; var arguments = new[] { shortName, longName }.Where(i => !string.IsNullOrEmpty(i)); - foreach (var argument in arguments) + foreach (var argument in arguments.Where(argument => dictionary.ContainsKey(argument))) { - if (dictionary.ContainsKey(argument)) + // if the backing type is an array, it supports multiple values. + if (property.PropertyType.IsArray) { - // if the backing type is an array, it supports multiple values. - if (property.PropertyType.IsArray) - { - var value = dictionary[argument]; + var value = dictionary[argument]; - // Parse() will stuff multiple values into a List if the argument name is - // in the list of those supporting multiple values, and more than one value was supplied. - // detect this, and add the values to the target. - if (value.GetType().IsGenericType && value.GetType().GetGenericTypeDefinition() == typeof(List<>)) - { - var elements = (List)dictionary[argument]; + // Parse() will stuff multiple values into a List if the argument name is + // in the list of those supporting multiple values, and more than one value was supplied. + // detect this, and add the values to the target. + if (value.GetType().IsGenericType && value.GetType().GetGenericTypeDefinition() == typeof(List<>)) + { + var elements = (List)dictionary[argument]; - for (int i = 0; i < elements.Count; i++) - { - Data[ConfigurationPath.Combine(key, i.ToString())] = elements[i].ToString(); - } - } - else + for (int i = 0; i < elements.Count; i++) { - // there may have only been one value supplied, in which case the value is just a - // string. stick it in index 0 of the target. - Data[ConfigurationPath.Combine(key, "0")] = value.ToString(); + Data[ConfigurationPath.Combine(key, i.ToString())] = elements[i].ToString(); } } else { - var value = dictionary[argument].ToString(); - - if (property.PropertyType == typeof(bool) && string.IsNullOrEmpty(value)) - { - value = "true"; - } + // there may have only been one value supplied, in which case the value is just a + // string. stick it in index 0 of the target. + Data[ConfigurationPath.Combine(key, "0")] = value.ToString(); + } + } + else + { + var value = dictionary[argument].ToString(); - Data[key] = value; + if (property.PropertyType == typeof(bool) && string.IsNullOrEmpty(value)) + { + value = "true"; } + + Data[key] = value; } } } -- cgit v1.2.3