Пример #1
0
        private DirectoryCache Load(DirectoryCache parent, DirectoryInfo directory)
        {
            var directoryCache = new DirectoryCache(directory, parent);

            RaiseCreatedEvent(directoryCache);

            //todo: deal with exceptions
            try
            {
                var subDirectories = directory.GetDirectories();
                foreach (var subDirectory in subDirectories)
                {
                    var subDirectoryCache = Load(directoryCache, subDirectory);
                }
                var files = directory.GetFiles();
                foreach (var file in files)
                {
                    var fileCache = Load(file, directoryCache);
                }
            }
            catch (System.UnauthorizedAccessException ex)
            {
                // handle exception
                //throw;
            }


            RaiseLoadedEvent(directoryCache);

            return(directoryCache);
        }
Пример #2
0
        private FileCache Load(FileInfo file, DirectoryCache parent)
        {
            var fileCache = new FileCache(file, parent);

            RaiseCreatedEvent(fileCache);
            RaiseLoadedEvent(fileCache);
            return(fileCache);
        }
Пример #3
0
        public DirectoryCache(DirectoryInfo directoryInfo, DirectoryCache parent)
        {
            this.Info   = directoryInfo;
            this.parent = parent;
            if (parent == null)
            {
                return;
            }

            parent?.directories.Add(this);
        }
Пример #4
0
        private void Load(string directory, DirectoryCache parent)
        {
            var info = new DirectoryInfo(directory);

            drivesCache.Add(Load(parent, info));
        }
Пример #5
0
 public FileCache(FileInfo file, DirectoryCache parent)
 {
     this.Info   = file;
     this.parent = parent;
     parent?.files.Add(this);
 }