Example #1
0
        public PhysicalAppDataFolder(
            IPlatoFileSystem parentFileSystem,
            ILogger <PhysicalAppDataFolder> logger)
        {
            _logger = logger;

            if (!parentFileSystem.DirectoryExists(InternalRootPath))
            {
                parentFileSystem.CreateDirectory(InternalRootPath);
            }

            var root = parentFileSystem.GetDirectoryInfo(InternalRootPath).FullName;

            _fileSystem = new PlatoFileSystem(root, new PhysicalFileProvider(root), _logger);
        }
Example #2
0
        public PhysicalSitesFolder(
            IPlatoFileSystem parentFileSystem,
            ILogger <PhysicalSitesFolder> logger,
            IHostEnvironment hostEnvironment)
        {
            _logger          = logger;
            _hostEnvironment = hostEnvironment;

            if (!parentFileSystem.DirectoryExists(InternalRootPath))
            {
                parentFileSystem.CreateDirectory(InternalRootPath);
            }

            var root = parentFileSystem.GetDirectoryInfo(InternalRootPath).FullName;

            _fileSystem = new PlatoFileSystem(root, new PhysicalFileProvider(root), _logger);
        }
Example #3
0
        private async Task <List <Assembly> > LoadAssembliesInFolder(
            string path, List <Assembly> localList)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(localList);
            }

            // no bin folder within module
            if (!_fileSystem.DirectoryExists(path))
            {
                return(localList);
            }

            var folder = _fileSystem.GetDirectoryInfo(path);

            foreach (var file in folder.GetFiles())
            {
                if (file.Extension.ToLower() == AssemblyExtension)
                {
                    if (!IsAssemblyLoaded(Path.GetFileNameWithoutExtension(file.FullName)))
                    {
                        var assembly = LoadFromAssemblyPath(file.FullName);
                        if (assembly != null)
                        {
                            localList.Add(assembly);
                        }
                    }
                }
            }

            // Recursive lookup
            var subFolders = Directory.GetDirectories(path);

            for (var i = 0; i <= subFolders.Length - 1; i++)
            {
                await LoadAssembliesInFolder(subFolders.GetValue(i).ToString(), localList);
            }

            return(localList);
        }
Example #4
0
 public DirectoryInfo GetDirectoryInfo(string path)
 {
     return(_fileSystem.GetDirectoryInfo(path));
 }
Example #5
0
        public IEnumerable <IThemeFile> GetFiles(string themeId)
        {
            // Ensure theme loader
            EnsureThemeLoader();

            // Get available themes
            var availableThemes = _themeLoader.AvailableThemes;

            if (availableThemes == null)
            {
                throw new Exception($"Could not list files for theme \"{themeId}\". No themes could be located!");
            }

            // Get theme to list
            var theme = availableThemes.FirstOrDefault(t => t.Id.Equals(themeId, StringComparison.OrdinalIgnoreCase));

            if (theme == null)
            {
                throw new Exception($"A theme folder named \"{themeId}\" could not be found!");
            }

            // Build output
            var output = new List <IThemeFile>();

            // Get theme directory
            var themeDirectory = _fileSystem.GetDirectoryInfo(theme.FullPath);

            // Add our theme directory as the root
            var rootDirectory = new ThemeFile
            {
                Name        = themeDirectory.Name,
                FullName    = themeDirectory.FullName,
                IsDirectory = true
            };

            // Add child directories to our root
            var directories = BuildDirectoriesRecursively(theme.FullPath, rootDirectory);

            if (directories != null)
            {
                foreach (var childDirectory in directories)
                {
                    output.Add(childDirectory);
                }
            }

            // Add files from our theme directory
            foreach (var file in themeDirectory.GetFiles())
            {
                output.Add(new ThemeFile()
                {
                    Name     = file.Name,
                    FullName = file.FullName,
                    Parent   = rootDirectory
                });
            }

            // We need an explicit type to pass by reference
            var list = ((IList <IThemeFile>)output.ToList());

            // Update list with relative paths
            // We pass by reference so we don't need to create another list
            BuildRelativePathsRecursively(ref list, _fileSystem.MapPath(theme.FullPath));

            // Return composed theme files
            return(list);
        }