All pastes #369141 Raw Edit

Mine

public text v1 · immutable
#369141 ·published 2007-02-23 16:23 UTC
rendered paste body
            private void ParseNumericReply(string message, string sender, string command, string[] words)
            {
                //Update the real url if not already done
                if (container.realUrl == String.Empty)
                    container.realUrl = sender;

                string[] targets;
                string payload;

                // Payload starts after the second colon
                if (command != "352")
                {
                    int payloadIndex = message.IndexOf(':', 1);
                    payload = (payloadIndex != -1) ? message.Substring(payloadIndex + 1) : String.Empty;


                    // targets are between command and the payload
                    int targetStringIndex = message.IndexOf(command) + command.Length + 1;
                    string targetString = message.Substring(
                        targetStringIndex,
                        (payloadIndex != -1) ? (payloadIndex - targetStringIndex) : (message.Length - targetStringIndex));

                    targets = null;
                    if (targetString.Trim().Length > 0)
                        targets = targetString.Split(Separators.Word, StringSplitOptions.RemoveEmptyEntries);
                }
                else
                {
                    // host and gecos fields can both contain ':' so RPL_WHOREPLY
                    // must be parsed differently

                    // gecos field starts at index 9, targets start at index 2
                    targets = new string[7];
                    Array.Copy(words, 2, targets, 0, 7);

                    payload = String.Join(" ", words, 10, words.Length - 10); 
                }
                container.OnReplyReceived(message, int.Parse(command), targets, payload);
            }