Пример #1
0
        private static bool add_arg_if_not_exist(List <string> args, OptionSet option_set, Option option_to_replace, string new_value)
        {
            for (int i = 0; i < args.Count; i++)
            {
                var arg = args[i];
                if (!string.IsNullOrEmpty(arg))
                {
                    string arg_flag;
                    string arg_name;
                    string arg_sep;
                    string arg_value;
                    if (option_set.GetOptionParts(arg, out arg_flag, out arg_name, out arg_sep, out arg_value))
                    {
                        foreach (var name in option_to_replace.GetNames())
                        {
                            if (!string.IsNullOrEmpty(name) && name.Equals(arg_name, StringComparison.CurrentCultureIgnoreCase))
                            {
                                //Value already exists, skip this, command line should take precedence.
                                return(false);
                            }
                        }
                    }
                }
            }
            string new_arg = "/" + option_to_replace.GetNames()[0] + "=" + new_value;

            args.Add(new_arg);
            return(true);
        }