Yaircc.Net.IRC.ModeMessage.ParseModeCommand C# (CSharp) Method

ParseModeCommand() private method

Parse a mode command into the message.
private ParseModeCommand ( string payload ) : ParseResult
payload string The raw mode command.
return ParseResult
        private ParseResult ParseModeCommand(string payload)
        {
            ParseResult retval;
            string pattern = @"/mode(\s+(?<target>[^\s]+))?(\s+(?<modestr>[^\s]+))?(\s+(?<args>.+))?";
            Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
            Match match = regex.Match(payload);

            if (match.Success)
            {
                List<string> parameters = new List<string>();

                if (match.Groups["target"].Success)
                {
                    parameters.Add(match.Groups["target"].Value);

                    if (match.Groups["modestr"].Success)
                    {
                        parameters.Add(match.Groups["modestr"].Value);

                        if (match.Groups["args"].Success)
                        {
                            parameters.AddRange(match.Groups["args"].Value.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries));
                        }
                    }
                }

                this.Parameters = parameters.ToArray();
                retval = new ParseResult(true, string.Empty);
            }
            else
            {
                retval = new ParseResult(false, string.Empty);
            }

            return retval;
        }