Beispiel #1
0
        public override IEnumerable <FileManagerFile> GetFiles(FileManagerFolder folder)
        {
            FileSystemData folderItem = FindFolderItem(folder);

            return
                (from dbItem in DataSource
                 where !dbItem.IsFolder && dbItem.ParentId == folderItem.Id
                 select new FileManagerFile(this, folder, dbItem.Name));
        }
Beispiel #2
0
        public override IEnumerable <FileManagerFolder> GetFolders(FileManagerFolder parentFolder)
        {
            FileSystemData dbFolderItem = FindFolderItem(parentFolder);

            return
                (DataSource
                 .Where(x => x.IsFolder && x.ParentId == dbFolderItem.Id)
                 .OrderByDescending(x => x.Name)
                 .Select(x => new FileManagerFolder(this, parentFolder, x.Name)));
        }
Beispiel #3
0
        protected FileSystemData FindFileItem(FileManagerFile file)
        {
            FileSystemData        folderItem = FindFolderItem(file.Folder);
            List <FileSystemData> files      = DataSource.Where(x => !x.IsFolder).ToList();

            if (folderItem == null)
            {
                return(null);
            }
            return
                ((from dbItem in files
                  where dbItem.ParentId == folderItem.Id && !dbItem.IsFolder && dbItem.Name == file.Name
                  select dbItem).FirstOrDefault());
        }
Beispiel #4
0
        protected string GetRelativeName(FileSystemData folder)
        {
            FileSystemData root = GetRootFolder();

            if (folder.Id == root.Id)
            {
                return(string.Empty);
            }
            if (folder.ParentId == root.Id)
            {
                return(folder.Name);
            }
            var    folders = DataSource.Where(x => x.IsFolder);
            string name    = GetRelativeName(folders.Where(x => x.Id == folder.ParentId).FirstOrDefault());

            return(name == null ? null : Path.Combine(name, folder.Name));
        }
Beispiel #5
0
        public override void RenameFolder(FileManagerFolder folder, string name)
        {
            FileSystemData item = FindFolderItem(folder);

            item.Name = name;
        }
Beispiel #6
0
        public override void RenameFile(FileManagerFile file, string name)
        {
            FileSystemData item = FindFileItem(file);

            item.Name = name;
        }
Beispiel #7
0
        public override void MoveFolder(FileManagerFolder folder, FileManagerFolder newParentFolder)
        {
            FileSystemData item = FindFolderItem(folder);

            item.ParentId = FindFolderItem(newParentFolder).Id;
        }
Beispiel #8
0
        public override void MoveFile(FileManagerFile file, FileManagerFolder newParentFolder)
        {
            FileSystemData item = FindFileItem(file);

            item.ParentId = FindFolderItem(newParentFolder).Id;
        }
Beispiel #9
0
        public override void DeleteFolder(FileManagerFolder folder)
        {
            FileSystemData item = FindFolderItem(folder);

            DataSource.Remove(item);
        }
Beispiel #10
0
        public override void DeleteFile(FileManagerFile file)
        {
            FileSystemData item = FindFileItem(file);

            DataSource.Remove(item);
        }