/// <summary>
 /// Adds a custom message to consider for parsing raw messages recevied from the server.
 /// </summary>
 /// <param name="msg"></param>
 public void AddCustomMessage( IrcMessage msg )
 {
     if ( this.customs == null )
     {
         this.customs = new PrioritizedMessageList();
     }
     customs.AddLast( msg );
 }
 private void logUnimplementedMessage( IrcMessage msg )
 {
     System.Diagnostics.Trace.WriteLine( msg.ToString(), "Unimplemented Message" );
 }
        /// <summary>
        /// Sends a <see cref="IrcMessage"/> over a <see cref="ClientConnection"/> to an irc server.
        /// </summary>
        /// <param name="message">The <see cref="IrcMessage"/> to send.</param>
        public virtual void Send( IrcMessage message )
        {
            if ( message == null )
            {
                return;
            }

            CancelIrcMessageEventArgs<IrcMessage> e = new CancelIrcMessageEventArgs<IrcMessage>( message );
            this.OnMessageSending( e );
            if ( e.Cancel )
            {
                return;
            }

            TextWriter originalWriter = this.writer.InnerWriter;
            using ( StringWriter myInnerWriter = new StringWriter( CultureInfo.InvariantCulture ) )
            {
                this.writer.InnerWriter = myInnerWriter;

                message.Validate( this.ServerSupports );
                message.Format( writer );
                this.Connection.Write( myInnerWriter.ToString() );

                this.writer.InnerWriter = originalWriter;
            }
        }