public static CommandParameterGroupList Parse(string source) { if (source.IsNullOrTrimmedEmpty()) { return(new CommandParameterGroupList()); } CommandParameterGroupList result = new CommandParameterGroupList(); foreach (string groupText in source.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)) { CommandParameterGroup group = new CommandParameterGroup(); foreach (string parameterText in Regex.Split(groupText, " +", RegexOptions.Singleline)) { int equalSignIndex = parameterText.IndexOf('='); if (equalSignIndex > 0) { group.Add(new CommandParameter(parameterText.Substring(0, equalSignIndex), Ts3Util.DecodeString(parameterText.Substring(equalSignIndex + 1)))); } else if (equalSignIndex == -1) { group.Add(new CommandParameter(Ts3Util.DecodeString(parameterText))); } } if (group.Count > 0) { result.Add(group); } } return(result); }
public Command(string commandName, params string[] options) { if (commandName.IsNullOrTrimmedEmpty()) { throw new ArgumentException("commandName is null or emtpy", "commandName"); } Name = commandName; ParameterGroups = new CommandParameterGroupList(); Options = new List <string>(); if (options != null && options.Length > 0) { foreach (string option in options) { AddOption(option); } } }