Example #1
0
        public uint GetBlobIndex(byte[] blobValue)
        {
            ReadAllBlobs();

            if (_readBlobs.ContainsValue(blobValue))
            {
                return(_readBlobs.FirstOrDefault(b => b.Value == blobValue).Key);
            }

            _mainStream.Seek(0, SeekOrigin.End);
            uint index = (uint)_mainStream.Position;

            NETGlobals.WriteCompressedUInt32(_binWriter, (uint)blobValue.Length);
            _binWriter.Write(blobValue);
            _readBlobs.Add(index, blobValue);
            return(index);
        }
Example #2
0
        internal void Reconstruct()
        {
            // will be removed once blobs are being serialized.

            MemoryStream newStream = new MemoryStream();
            BinaryWriter writer    = new BinaryWriter(newStream);

            writer.Write((byte)0);
            ReadAllBlobs();

            foreach (var blob in _readBlobs)
            {
                NETGlobals.WriteCompressedUInt32(writer, (uint)blob.Value.Length);
                writer.Write(blob.Value);
            }

            _mainStream.Dispose();
            _binReader.Dispose();
            _binWriter.Dispose();
            _mainStream             = newStream;
            _binReader              = new BinaryReader(newStream);
            _binWriter              = new BinaryWriter(newStream);
            this._streamHeader.Size = (uint)newStream.Length;
        }