protected virtual IItemData ReadItem(string path) { Assert.ArgumentNotNullOrEmpty(path, "path"); var item = _dataCache.GetValue(path, fileInfo => { try { using (var reader = fileInfo.OpenRead()) { var readItem = _formatter.ReadSerializedItem(reader, path); readItem.DatabaseName = DatabaseName; AddToMetadataCache(readItem); return(readItem); } } catch (Exception exception) { throw new SfsReadException("Error while reading SFS item " + path, exception); } }); // when the data cache is enabled we have to 'restore' the item's children to it // (this allows us to successfully move and rename data cached items) if (_dataCache.Enabled && item != null) { return(new FsCachedItem(item, () => GetChildren(item))); } return(item); }
protected virtual IItemMetadata ReadItemMetadata(string path) { Assert.ArgumentNotNullOrEmpty(path, "path"); return(_metadataCache.GetValue(path, fileInfo => { try { using (var reader = fileInfo.OpenRead()) { var readItem = _formatter.ReadSerializedItemMetadata(reader, path); _idCache[readItem.Id] = readItem; return readItem; } } catch (Exception exception) { throw new SfsReadException("Error while reading SFS metadata " + path, exception); } })); }
protected virtual IItemData ReadItem(string path) { Assert.ArgumentNotNullOrEmpty(path, "path"); return(_dataCache.GetValue(path, fileInfo => { try { using (var reader = fileInfo.OpenRead()) { var readItem = _formatter.ReadSerializedItem(reader, path); readItem.DatabaseName = DatabaseName; AddToMetadataCache(readItem); return readItem; } } catch (Exception exception) { throw new SfsReadException("Error while reading SFS item " + path, exception); } })); }