public int ReadFrom(byte[] buffer, int offset)
        {
            ItemId = Utilities.ToGuidLittleEndian(buffer, offset + 0);
            Offset = Utilities.ToUInt32LittleEndian(buffer, offset + 16);
            Length = Utilities.ToUInt32LittleEndian(buffer, offset + 20);
            Flags = (MetadataEntryFlags)Utilities.ToUInt32LittleEndian(buffer, offset + 24);
            Reserved = Utilities.ToUInt32LittleEndian(buffer, offset + 28);

            return 32;
        }
Example #2
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            ItemId   = Utilities.ToGuidLittleEndian(buffer, offset + 0);
            Offset   = Utilities.ToUInt32LittleEndian(buffer, offset + 16);
            Length   = Utilities.ToUInt32LittleEndian(buffer, offset + 20);
            Flags    = (MetadataEntryFlags)Utilities.ToUInt32LittleEndian(buffer, offset + 24);
            Reserved = Utilities.ToUInt32LittleEndian(buffer, offset + 28);

            return(32);
        }
Example #3
0
        private static uint AddEntryStruct <T>(T data, Guid id, MetadataEntryFlags flags, MetadataTable header, uint dataOffset, Stream stream)
            where T : IByteArraySerializable
        {
            MetadataEntryKey key   = new MetadataEntryKey(id, (flags & MetadataEntryFlags.IsUser) != 0);
            MetadataEntry    entry = new MetadataEntry();

            entry.ItemId = id;
            entry.Offset = dataOffset;
            entry.Length = (uint)data.Size;
            entry.Flags  = flags;

            header.Entries[key] = entry;

            stream.Position = dataOffset;
            Utilities.WriteStruct(stream, data);

            return(entry.Length);
        }
Example #4
0
        private static uint AddEntryValue <T>(T data, Writer <T> writer, Guid id, MetadataEntryFlags flags, MetadataTable header, uint dataOffset, Stream stream)
        {
            MetadataEntryKey key   = new MetadataEntryKey(id, (flags & MetadataEntryFlags.IsUser) != 0);
            MetadataEntry    entry = new MetadataEntry();

            entry.ItemId = id;
            entry.Offset = dataOffset;
            entry.Length = (uint)Marshal.SizeOf(typeof(T));
            entry.Flags  = flags;

            header.Entries[key] = entry;

            stream.Position = dataOffset;

            byte[] buffer = new byte[entry.Length];
            writer(data, buffer, 0);
            stream.Write(buffer, 0, buffer.Length);

            return(entry.Length);
        }