Beispiel #1
0
        public async Task SaveFileAsync(IThemeFile themeFile, string contents)
        {
            if (themeFile == null)
            {
                throw new ArgumentNullException(nameof(themeFile));
            }

            if (themeFile.IsDirectory)
            {
                return;
            }

            await _fileSystem.SaveFileAsync(themeFile.FullName, contents);
        }
Beispiel #2
0
        public async Task <string> ReadFileAsync(IThemeFile themeFile)
        {
            if (themeFile == null)
            {
                return(string.Empty);
            }

            if (themeFile.IsDirectory)
            {
                return(string.Empty);
            }

            return(await _fileSystem.ReadFileAsync(themeFile.FullName));
        }
Beispiel #3
0
        IEnumerable <IThemeFile> BuildParentsRecursively(IThemeFile themeFile, IList <IThemeFile> output = null)
        {
            if (output == null)
            {
                output = new List <IThemeFile>();
            }

            if (themeFile.Parent != null)
            {
                output.Add(themeFile);
                BuildParentsRecursively(themeFile.Parent, output);
            }
            else
            {
                output.Add(themeFile);
            }

            return(output);
        }
Beispiel #4
0
        IEnumerable <IThemeFile> BuildDirectoriesRecursively(string path, IThemeFile parent = null)
        {
            // Recurse directories
            var themeDirectory = _fileSystem.GetDirectoryInfo(path);

            foreach (var directory in themeDirectory.GetDirectories())
            {
                // Add directory
                var themeFile = new ThemeFile
                {
                    Name        = directory.Name,
                    FullName    = directory.FullName,
                    Parent      = parent,
                    IsDirectory = true
                };

                // Add files to directory
                foreach (var file in directory.GetFiles())
                {
                    themeFile.Children.Add(new ThemeFile()
                    {
                        Name     = file.Name,
                        FullName = file.FullName,
                        Parent   = themeFile
                    });
                }

                // Add current file as a child of the parent
                parent?.Children.Add(themeFile);

                // Recurse until we've processed all directories
                BuildDirectoriesRecursively(directory.FullName, themeFile);
            }

            return(parent?.Children ?? null);
        }
 public async Task SaveFileAsync(IThemeFile themeFile, string contents)
 {
     await _themeFileManager.SaveFileAsync(themeFile, contents);
 }
 public async Task <string> ReadFileAsync(IThemeFile themeFile)
 {
     return(await _themeFileManager.ReadFileAsync(themeFile));
 }