/// <summary> /// Writes an Int32 value type content and returns its location for possible further update. /// </summary> /// <param name="number">Int32 value to write.</param> /// <param name="chunk">Chunk the value was stored at.</param> /// <param name="position">Chunk location where the value was saved.</param> public void WriteInt32AndRememberItsLocation(int number, out byte[] chunk, out int position) { if (this._disposed) { throw new ObjectDisposedException("GenuineChunkedStream"); } if (this._currentWriteBlock == null || this._writePosition >= this._currentWriteBlock.Length - 4) { this.ObtainNextBuffer(); } // set returned values chunk = this._currentWriteBlock; position = this._writePosition; // write the value MessageCoder.WriteInt32(this._currentWriteBlock, this._writePosition, number); // and advance the pointer this._writePosition += 4; this._chunksAndStreams[this._chunksAndStreams.Count - 1] = this._writePosition; if (this._length >= 0) { this._length += 4; } }
/// <summary> /// Updates the difference of the length property. /// </summary> public void Dispose() { MessageCoder.WriteInt32(this._chunk, this._position, (int)(this._outputStream.Length - this._initialLength)); }