private static IEnumerable <string> GetEnvironmentVariableAndDefaultValue(ArgumentAttribute attribute, Func <string, string> getEnvironmentVariable = null) { var results = new List <string>(); if (!string.IsNullOrWhiteSpace(attribute.EnvVar)) { var item = (getEnvironmentVariable ?? Environment.GetEnvironmentVariable)(attribute.EnvVar); if (item != null) { results.Add(item); } } if (!string.IsNullOrEmpty(attribute.Default)) { results.Add(attribute.Default); } return(results); }
private static bool ParseArgumentValue(ArgumentAttribute attribute, object target, PropertyInfo propertyInfo, string[] args) { for (var index = 0; index < args.Length; index++) { var arg = args[index]; if (!arg.Equals(attribute.ShortName) && !arg.Equals(attribute.LongName)) { continue; } if (propertyInfo.PropertyType == typeof(bool)) { propertyInfo.SetValue(target, true); return(true); } var value = index + 1 < args.Length ? args[index + 1] : null; propertyInfo.SetValue(target, value); return(true); } return(false); }