Ejemplo n.º 1
0
 public BrowseViewModel(Library currentLibrary, string relativePath, IEnumerable<FileResult> results)
 {
     CurrentLibrary = currentLibrary;
     RelativePath = relativePath;
     Results = results;
     PathCrumbs = GetAllSubPathsContainedWithinRelativePath(relativePath);
 }
Ejemplo n.º 2
0
        public bool TryGetLibrary(int? libraryId, out Library library)
        {
            if (!libraryId.HasValue)
            {
                library = null;
                return false;
            }

            library = FetchLibraries().First(x => x.LibraryId == libraryId);
            return (library != null);
        }
Ejemplo n.º 3
0
        public IEnumerable<FileResult> FetchResultsForPath(Library library, string relativePath)
        {
            string fullPath = string.Format("{0}{1}", library.FullPathName, relativePath);

            if (!library.IsDescendant(fullPath))
                throw new HttpException(403,"No no no!");

            var folders = FileSystemEnumerator.GetDirectories(fullPath, "*.*");
            foreach (string r in folders)
            {

                yield return new FileResult(library.MakePathRelativeToLibrary(r), true);
            }

            var files = FileSystemEnumerator.GetFiles(fullPath, "*.*");
            foreach (string r in files)
            {
                yield return new FileResult(library.MakePathRelativeToLibrary(r), false);
            }
        }