Example #1
0
        public async Task SaveUpkFile(DomainHeader Header, string Filename)
        {
            if (Header == null)
            {
                return;
            }

            foreach (DomainExportTableEntry export in Header.ExportTable.Where(export => export.DomainObject == null))
            {
                await export.ParseDomainObject(Header, false, false);
            }

            FileStream stream = new FileStream(Filename, FileMode.Create);

            int headerSize = Header.GetBuilderSize();

            ByteArrayWriter writer = ByteArrayWriter.CreateNew(headerSize);

            await Header.WriteBuffer(writer, 0);

            await stream.WriteAsync(writer.GetBytes(), 0, headerSize);

            foreach (DomainExportTableEntry export in Header.ExportTable)
            {
                ByteArrayWriter objectWriter = await export.WriteObjectBuffer();

                await stream.WriteAsync(objectWriter.GetBytes(), 0, objectWriter.Index);
            }

            await stream.FlushAsync();

            stream.Close();
        }
Example #2
0
        public override async Task <ByteArrayWriter> WriteObjectBuffer()
        {
            ByteArrayWriter writer = ByteArrayWriter.CreateNew(SerialDataSize);

            await DomainObject.WriteBuffer(writer, SerialDataOffset);

            return(writer);
        }