/// <summary>
        ///		Process response message before serialization.
        /// </summary>
        /// <param name="context">Context information of serializing message.</param>
        internal void Process( ResponseMessageSerializationContext context )
        {
            Contract.Assert( context != null );

            this.ProcessCore( context );
        }
 /// <summary>
 ///		Process response message before serialization.
 /// </summary>
 /// <param name="context">Context information of serializing message.</param>
 protected abstract void ProcessCore( ResponseMessageSerializationContext context );
 private static void SerializeCore( MessageType messageType, int messageId, ResponseMessageSerializationContext context )
 {
     using ( var stream = context.Buffer.OpenWriteStream() )
     using ( var packer = Packer.Create( stream ) )
     {
         packer.PackArrayHeader( 4 );
         packer.Pack( ( int )messageType );
         packer.Pack( unchecked( ( uint )messageId ) );
         if ( context.Exception == null )
         {
             packer.PackNull();
             packer.PackObject( context.ReturnValue );
         }
         else
         {
             packer.PackString( context.Exception.RpcError.Identifier );
             packer.Pack( context.Exception.GetExceptionMessage( false ) );
         }
     }
 }