public IAsyncResult BeginWriteToStream(Stream stream, AsyncCallback callback, object state)
        {
            Fx.Assert(stream != null, "stream should not be null.");
            MtomMessageEncoder mtomMessageEncoder = this.messageEncoder as MtomMessageEncoder;

            if (mtomMessageEncoder == null)
            {
                return(this.messageEncoder.BeginWriteMessage(this.message, stream, callback, state));
            }
            else
            {
                return(mtomMessageEncoder.BeginWriteMessage(this.message, stream, this.mtomBoundary, callback, state));
            }
        }