Esempio n. 1
0
        public override Task <IResult <SystemFolder> > AddChildFolderAsync(string name)
        {
            if (_childFolderNameToCacheFolder == null)
            {
                return(base.AddChildFolderAsync(name));
            }

            if (_childFolderNameToCacheFolder.TryGetValue(name, out var childFolder))
            {
                return(Success <SystemFolder>(childFolder));
            }

            Task.Run(async() =>
            {
                var childFolderResult = await base.AddChildFolderAsync(name);

                if (childFolderResult.IsSuccess)
                {
                    var childCacheFolder = new CacheFolder(
                        DirectoryManager,
                        PathManager,
                        FileManager,
                        childFolderResult.Data.RelativePath,
                        Configuration,
                        this);

                    _childFolderNameToCacheFolder.TryAdd(name, childCacheFolder);

                    ClearPageCache();
                }
            });

            return(Failure <SystemFolder>($"Could not add child folder with name {name} to {RelativePath}. Please try again..."));
        }
Esempio n. 2
0
        private CacheFolder GetRootCacheFolder()
        {
            CacheFolder current = this;

            while (current._parent != null)
            {
                current = current._parent;
            }

            return(current);
        }
Esempio n. 3
0
        private CacheFolder GetMatchedCacheFolder(SystemFolder folderToFind, CacheFolder folderToLookIn)
        {
            if (folderToLookIn._childFolderNameToCacheFolder.TryGetValue(folderToFind.Name, out var cacheFolder) &&
                cacheFolder.Equals(folderToFind))
            {
                return(cacheFolder);
            }

            return(folderToLookIn._childFolderNameToCacheFolder.Values
                   .Select(childFolder => GetMatchedCacheFolder(folderToFind, childFolder))
                   .FirstOrDefault());
        }
Esempio n. 4
0
        public CacheFolder(
            IDirectoryManagerAsync directoryManager,
            IPathManager pathManager,
            IFileManagerAsync fileManager,
            string relativePath,
            IConfiguration configuration,
            CacheFolder parent) :
            base(directoryManager, pathManager, fileManager, relativePath, configuration)
        {
            _parent = parent;

            LoadCache(directoryManager, pathManager, fileManager, configuration);
        }
Esempio n. 5
0
 public SearchFolder(
     IDirectoryManagerAsync directoryManager,
     IPathManager pathManager,
     IFileManagerAsync fileManager,
     string relativePath,
     IConfiguration configuration,
     CacheFolder parent)
     : base(directoryManager, pathManager, fileManager, relativePath, configuration, parent)
 {
     CreationTime = ModificationTime = $"{DateTime.Now:G}";
     Name         = FolderName;
     Type         = FolderContentType.FolderPageResult;
 }