IrcDotNet.IrcClient.GetMessageTarget C# (CSharp) Method

GetMessageTarget() protected method

Gets the target of a message from the specified name. A message target may be an IrcUser, IrcChannel, or IrcTargetMask.
/// does not represent a valid message target. ///
protected GetMessageTarget ( string targetName ) : IIrcMessageTarget
targetName string The name of the target.
return IIrcMessageTarget
        protected IIrcMessageTarget GetMessageTarget(string targetName)
        {
            if (targetName == null)
                throw new ArgumentNullException("targetName");
            if (targetName.Length == 0)
                throw new ArgumentException(Resources.MessageValueCannotBeEmptyString, "targetName");

            // Check whether target name represents channel, user, or target mask.
            var targetNameMatch = Regex.Match(targetName, regexMessageTarget);
            var channelName = targetNameMatch.Groups["channel"].GetValue();
            var nickName = targetNameMatch.Groups["nick"].GetValue();
            var userName = targetNameMatch.Groups["user"].GetValue();
            var hostName = targetNameMatch.Groups["host"].GetValue();
            var serverName = targetNameMatch.Groups["server"].GetValue();
            var targetMask = targetNameMatch.Groups["targetMask"].GetValue();
            if (channelName != null)
            {
                return GetChannelFromName(channelName);
            }
            if (nickName != null)
            {
                // Find user by nick name. If no user exists in list, create it and set its properties.
                var user = GetUserFromNickName(nickName, true);
                if (user.UserName == null)
                    user.UserName = userName;
                if (user.HostName == null)
                    user.HostName = hostName;

                return user;
            }
            if (userName != null)
            {
                // Find user by user  name. If no user exists in list, create it and set its properties.
                var user = GetUserFromNickName(nickName, true);
                if (user.HostName == null)
                    user.HostName = hostName;

                return user;
            }
            if (targetMask != null)
            {
                return new IrcTargetMask(targetMask);
            }
            throw new ArgumentException(string.Format(
                Resources.MessageInvalidSource, targetName), "targetName");
        }
IrcClient