Beispiel #1
0
        public bool TryGetOptionValue(string optionName, out string stringValue)
        {
            stringValue = String.Empty;

            for (int i = 0; i < elements.Count; i++)
            {
                ArgsParserElement element = elements[i];

                if (element.IsOption)
                {
                    if (String.Compare(element.Value, optionName, StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        int index = i;

                        if (TryGetString(index + 1, ref stringValue))
                        {
                            elements.RemoveAt(index + 1);
                            elements.RemoveAt(index);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Beispiel #2
0
        private bool TryGetOptionIndex(string optionName, out int index)
        {
            for (int i = 0; i < elements.Count; i++)
            {
                ArgsParserElement element = elements[i];

                if (element.IsOption)
                {
                    if (String.Compare(element.Value, optionName, StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        index = i;
                        elements.RemoveAt(index);
                        return(true);
                    }
                }
            }

            index = -1;
            return(false);
        }