PowerArgs.CommandLineArgumentsDefinition.FindMatchingArgument C# (CSharp) Method

FindMatchingArgument() public method

Finds the first CommandLineArgument that matches the given key.
public FindMatchingArgument ( string key, bool throwIfMoreThanOneMatch = false ) : CommandLineArgument
key string The key as if it was typed in on the command line. This can also be an alias.
throwIfMoreThanOneMatch bool If set to true then this method will throw and InvalidArgDeginitionException if more than 1 match is found
return CommandLineArgument
        public CommandLineArgument FindMatchingArgument(string key, bool throwIfMoreThanOneMatch = false)
        {
            return CommandLineArgumentsDefinition.FindMatchingArgument(key, throwIfMoreThanOneMatch, this.Arguments);
        }

Same methods

CommandLineArgumentsDefinition::FindMatchingArgument ( string key, bool throwIfMoreThanOneMatch, IEnumerable searchSpace ) : CommandLineArgument

Usage Example

示例#1
0
        private static bool IsBool(string key, CommandLineArgumentsDefinition definition, ParseResult resultContext)
        {
            var match = definition.FindMatchingArgument(key, true);

            if (match == null)
            {
                var possibleActionContext = resultContext.ImplicitParameters.ContainsKey(0) ? resultContext.ImplicitParameters[0] : null;

                if (possibleActionContext == null)
                {
                    return(false);
                }
                else
                {
                    var actionContext = definition.FindMatchingAction(possibleActionContext, true);
                    if (actionContext == null)
                    {
                        return(false);
                    }

                    match = actionContext.FindMatchingArgument(key, true);
                    if (match == null)
                    {
                        return(false);
                    }
                }
            }

            return(match.ArgumentType == typeof(bool));
        }
All Usage Examples Of PowerArgs.CommandLineArgumentsDefinition::FindMatchingArgument