Ejemplo n.º 1
0
        public XmlStorageIndex(IStorageDriver driver)
        {
            driver.ThrowIfNull(nameof(driver));

            _driver = driver;
            _items  = GetIndex(_driver);
        }
Ejemplo n.º 2
0
        private static StorageIndex GetIndex(IStorageDriver driver)
        {
            StorageIndex result = null;

            if (driver.Exists(IndexName))
            {
                try
                {
                    result = XmlClassSerializer.Load <StorageIndex>(driver.Read(IndexName));
                }
                catch (Exception)
                {
                    //TODO: log exception
                }
            }
            return(result ?? new StorageIndex {
                Items = new List <StorageItem>()
            });
        }