private void _GenerateStream()
{
//if the stream has already been created then don't bother
if (this._Output is DynamicStream) { return; }
//called just before the generation starts
this.OnBeforeGenerateStream();
//start building the header
DynamicStream stream = new DynamicStream(DEFAULT_HEADER_LENGTH);
stream.WriteAt(POSITION_OP_CODE, BitConverter.GetBytes((int)this.OpCode));
//generate the bytes to use for the body
this.GenerateBody(stream);
//update the request/response IDs incase they change when building
stream.WriteAt(POSITION_REQUEST_ID, BitConverter.GetBytes(this.RequestId));
stream.WriteAt(POSITION_RESPONSE_ID, BitConverter.GetBytes(this.ResponseId));
//finally, remember to update the length
stream.WriteAt(POSITION_REQUEST_LENGTH, BitConverter.GetBytes(stream.Length));
//cache this value to use it later
this._Output = stream;
}