예제 #1
0
        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 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);
                }
            }));
        }