IsInputValue() public static method

public static IsInputValue ( string argument ) : bool
argument string
return bool
Ejemplo n.º 1
0
        public override ParserState Parse(IStringEnumerator argumentEnumerator, OptionMap map, object options)
        {
            string[]   parts  = argumentEnumerator.Current.Substring(2).Split(new char[] { '=' }, 2);
            OptionInfo option = map[parts[0]];

            if (option == null)
            {
                return(ParserState.Failure);
            }
            option.IsDefined = true;
            if (!option.IsBoolean)
            {
                if (parts.Length == 1 && !argumentEnumerator.IsLast && !ArgumentParser.IsInputValue(argumentEnumerator.Next))
                {
                    return(ParserState.Failure);
                }
                if (parts.Length == 2)
                {
                    if (option.SetValue(parts[1], options))
                    {
                        return(ParserState.Success);
                    }
                    else
                    {
                        return(ParserState.Failure);
                    }
                }
                else
                {
                    if (option.SetValue(argumentEnumerator.Next, options))
                    {
                        return(ParserState.Success | ParserState.MoveOnNextElement);
                    }
                    else
                    {
                        return(ParserState.Failure);
                    }
                }
            }
            else
            {
                if (parts.Length == 2)
                {
                    return(ParserState.Failure);
                }
                if (option.SetValue(true, options))
                {
                    return(ParserState.Success);
                }
                else
                {
                    return(ParserState.Failure);
                }
            }
        }
        public override ParserState Parse(IStringEnumerator argumentEnumerator, OptionMap map, object options)
        {
            IStringEnumerator group = new CharEnumeratorEx(argumentEnumerator.Current.Substring(1));

            while (group.MoveNext())
            {
                OptionInfo option = map[group.Current];
                if (option == null)
                {
                    return(ParserState.Failure);
                }

                option.IsDefined = true;

                if (!option.IsBoolean)
                {
                    if (argumentEnumerator.IsLast && group.IsLast)
                    {
                        return(ParserState.Failure);
                    }

                    if (!group.IsLast)
                    {
                        if (option.SetValue(group.GetRemainingFromNext(), options))
                        {
                            return(ParserState.Success);
                        }
                        else
                        {
                            return(ParserState.Failure);
                        }
                    }

                    if (!argumentEnumerator.IsLast && !ArgumentParser.IsInputValue(argumentEnumerator.Next))
                    {
                        return(ParserState.Failure);
                    }
                    else
                    {
                        if (option.SetValue(argumentEnumerator.Next, options))
                        {
                            return(ParserState.Success | ParserState.MoveOnNextElement);
                        }
                        else
                        {
                            return(ParserState.Failure);
                        }
                    }
                }
                else
                {
                    if (!group.IsLast && map[group.Next] == null)
                    {
                        return(ParserState.Failure);
                    }
                    if (!option.SetValue(true, options))
                    {
                        return(ParserState.Failure);
                    }
                }
            }
            return(ParserState.Success);
        }