Beispiel #1
0
        private T ReadValue <T>(Guid itemId, bool isUser, Reader <T> reader)
        {
            MetadataEntryKey key = new MetadataEntryKey(itemId, isUser);
            MetadataEntry    entry;

            if (_table.Entries.TryGetValue(key, out entry))
            {
                _regionStream.Position = entry.Offset;
                byte[] data = Utilities.ReadFully(_regionStream, Marshal.SizeOf(typeof(T)));
                return(reader(data, 0));
            }

            return(default(T));
        }
Beispiel #2
0
        private T ReadStruct <T>(Guid itemId, bool isUser)
            where T : IByteArraySerializable, new()
        {
            MetadataEntryKey key = new MetadataEntryKey(itemId, isUser);
            MetadataEntry    entry;

            if (_table.Entries.TryGetValue(key, out entry))
            {
                _regionStream.Position = entry.Offset;
                return(Utilities.ReadStruct <T>(_regionStream));
            }

            return(default(T));
        }
Beispiel #3
0
        public int ReadFrom(byte[] buffer, int offset)
        {
            _headerData = new byte[32];
            Array.Copy(buffer, offset, _headerData, 0, 32);

            Signature  = Utilities.ToUInt64LittleEndian(_headerData, 0);
            EntryCount = Utilities.ToUInt16LittleEndian(_headerData, 10);

            Entries = new Dictionary <MetadataEntryKey, MetadataEntry>();
            if (IsValid)
            {
                for (int i = 0; i < EntryCount; ++i)
                {
                    MetadataEntry entry = Utilities.ToStruct <MetadataEntry>(buffer, offset + 32 + (i * 32));
                    Entries[MetadataEntryKey.FromEntry(entry)] = entry;
                }
            }

            return(FixedSize);
        }