private string ExtractCommandKey(CommandParsingContext context, string command) { var prefixes = context.GetPrefixes(); var separators = context.GetSeparators(); // Trim off any prefix characters from the start of the command and split on the first occurrence of any separator characters string commandKey = command.TrimStart(prefixes); int splitIndex = commandKey.IndexOfAny(separators); if (splitIndex > -1 && splitIndex < commandKey.Length) { commandKey = commandKey.Substring(0, splitIndex); } return(commandKey); }
private string ExtractCommandKey(CommandParsingContext context, string command) { var prefixes = context.GetPrefixes(); var separators = context.GetSeparators(); // Trim off any prefix characters from the start of the command and split on the first occurrence of any separator characters string commandKey = command.TrimStart(prefixes); int splitIndex = commandKey.IndexOfAny(separators); if (splitIndex > -1 && splitIndex < commandKey.Length) { commandKey = commandKey.Substring(0, splitIndex); } return commandKey; }
private object ExtractCommandValue(CommandParsingContext context, string command) { var separators = context.GetSeparators(); // Split the command from the first occurrence of any separator characters int splitIndex = command.IndexOfAny(separators); if (splitIndex < 0 || splitIndex >= command.Length) { return(null); } string commandValue = command.Substring(splitIndex + 1); // Check to see if we have multiple values if (commandValue.Contains(MultipleValuesSeparators[0])) { return(commandValue.Split(MultipleValuesSeparators, StringSplitOptions.RemoveEmptyEntries)); } // We have only a single value return(commandValue); }
private object ExtractCommandValue(CommandParsingContext context, string command) { var separators = context.GetSeparators(); // Split the command from the first occurrence of any separator characters int splitIndex = command.IndexOfAny(separators); if (splitIndex < 0 || splitIndex >= command.Length) { return null; } string commandValue = command.Substring(splitIndex + 1); // Check to see if we have multiple values if (commandValue.Contains(MultipleValuesSeparators[0])) { return commandValue.Split(MultipleValuesSeparators, StringSplitOptions.RemoveEmptyEntries); } // We have only a single value return commandValue; }