Esempio n. 1
0
        public T ReadMetadata <T>()
        {
            if (metadataCache?.GetType() == typeof(T))
            {
                return((T)metadataCache);
            }

            long             address;
            DependencyReader reader;

            if (ClassCode == "sbsp")
            {
                var translator = new BSPAddressTranslator(cache, Id);
                reader  = cache.CreateReader(translator);
                address = translator.TagAddress;
            }
            else if (ClassCode == "bitm" && MetaPointer.Address < 0)
            {
                reader = cache.CreateBitmapsReader();
                var translator = new BitmapsAddressTranslator(cache, this, reader);
                reader.RegisterInstance <IAddressTranslator>(translator);
                address = translator.TagAddress;
            }
            else
            {
                reader  = cache.CreateReader(cache.AddressTranslator);
                address = MetaPointer.Address;
            }

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

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

                return(result);
            }
        }
Esempio n. 2
0
 public BitmapsAddressTranslator(CacheFile cache, IndexItem tag)
     : this(cache, tag, cache.CreateBitmapsReader())
 {
 }