Exemplo n.º 1
0
        private T ReadMetadataInternal <T>()
        {
            long             address;
            DependencyReader reader;

            if (ClassCode == "sbsp")
            {
                var translator = new BSPAddressTranslator(cache, Id);
                reader  = cache.CreateReader(translator);
                address = translator.TagAddress;
            }
            else
            {
                reader  = cache.CreateReader(cache.MetadataTranslator);
                address = MetaPointer.Address;
            }

            using (reader)
            {
                reader.RegisterInstance <IIndexItem>(this);
                reader.Seek(address, SeekOrigin.Begin);
                var result = (T)reader.ReadObject(typeof(T), (int)cache.CacheType);

                if (CacheFactory.SystemClasses.Contains(ClassCode))
                {
                    metadataCache = result;
                }

                return(result);
            }
        }
Exemplo n.º 2
0
        internal void ReadItems()
        {
            using (var reader = cache.CreateReader(cache.HeaderTranslator))
            {
                var indices = new int[cache.Header.StringCount];
                reader.Seek(cache.Header.StringTableIndexAddress, SeekOrigin.Begin);
                for (int i = 0; i < cache.Header.StringCount; i++)
                {
                    indices[i] = reader.ReadInt32();
                }

                using (var reader2 = reader.CreateVirtualReader(cache.Header.StringTableAddress))
                {
                    for (int i = 0; i < cache.Header.StringCount; i++)
                    {
                        if (indices[i] < 0)
                        {
                            continue;
                        }

                        reader2.Seek(indices[i], SeekOrigin.Begin);
                        items[i] = reader2.ReadNullTerminatedString();
                    }
                }
            }
        }
Exemplo n.º 3
0
        internal void ReadItems()
        {
            if (items.Any())
            {
                throw new InvalidOperationException();
            }

            using (var reader = cache.CreateReader(cache.MetadataTranslator))
            {
                reader.Seek(cache.Header.IndexAddress + HeaderSize, SeekOrigin.Begin);
                for (int i = 0; i < TagCount; i++)
                {
                    var item = reader.ReadObject(new IndexItem(cache));
                    items.Add(i, item);
                }

                for (int i = 0; i < TagCount; i++)
                {
                    var item = items[i];

                    //change FileNamePointer to use HeaderTranslator instead of MetadataTranslator
                    item.FileNamePointer = new Pointer(item.FileNamePointer.Value, cache.HeaderTranslator);

                    reader.Seek(item.FileNamePointer.Address, SeekOrigin.Begin);
                    item.FullPath = reader.ReadNullTerminatedString();
                }
            }
        }