示例#1
0
        public byte[] FinalizeAndGetBinaryData()
        {
            BinaryWriter binaryWriter = BinaryWriterFactory.GetBinaryWriter();

            binaryWriter.WriteInt(this._folderCount);
            for (int index = 0; index < this._folderCount; ++index)
            {
                SaveEntryFolder     folder         = this._folders[index];
                int                 parentGlobalId = folder.ParentGlobalId;
                int                 globalId       = folder.GlobalId;
                int                 localId        = folder.FolderId.LocalId;
                SaveFolderExtension extension      = folder.FolderId.Extension;
                binaryWriter.Write3ByteInt(parentGlobalId);
                binaryWriter.Write3ByteInt(globalId);
                binaryWriter.Write3ByteInt(localId);
                binaryWriter.WriteByte((byte)extension);
            }
            binaryWriter.WriteInt(this._entryCount);
            binaryWriter.AppendData(this._writer);
            byte[] data = binaryWriter.Data;
            BinaryWriterFactory.ReleaseBinaryWriter(binaryWriter);
            BinaryWriterFactory.ReleaseBinaryWriter(this._writer);
            this._writer = (BinaryWriter)null;
            return(data);
        }
示例#2
0
        private void SerializeEntryConcurrent(SaveEntry entry, BinaryWriter writer)
        {
            BinaryWriter binaryWriter = BinaryWriterFactory.GetBinaryWriter();

            binaryWriter.Write3ByteInt(entry.FolderId);
            binaryWriter.Write3ByteInt(entry.Id.Id);
            binaryWriter.WriteByte((byte)entry.Id.Extension);
            binaryWriter.WriteShort((short)entry.Data.Length);
            binaryWriter.WriteBytes(entry.Data);
            byte[] data = binaryWriter.Data;
            BinaryWriterFactory.ReleaseBinaryWriter(binaryWriter);
            writer.WriteBytes(data);
            Interlocked.Increment(ref this._entryCount);
        }