public static FileSettings Load(ISettingsStore settings)
        {
            var model = new FileSettings
            {
                Version = settings.Get <int>(Constants.Settings.Version)
            };

            // Load included folders.
            var includeFolders = settings.Get <string>(Constants.Settings.Include.Folders);

            if (includeFolders != null)
            {
                model.IncludedFolders.AddRange(includeFolders
                                               .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
                                               .Select(s => new DirectoryPath(s)));
            }

            // Load included extensions.
            var includeExtensions = settings.Get <string>(Constants.Settings.Include.Extensions);

            if (!string.IsNullOrWhiteSpace(includeExtensions))
            {
                model.IncludedExtensions.AddRange(includeExtensions.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries));
            }

            // Load excluded folders.
            var excludeFolders = settings.Get <string>(Constants.Settings.Exclude.Folders);

            if (excludeFolders != null)
            {
                model.ExcludedFolders.AddRange(excludeFolders
                                               .Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
                                               .Select(s => new DirectoryPath(s)));
            }

            // Load excluded patterns.
            var excludePatterns = settings.Get <string>(Constants.Settings.Exclude.Patterns);

            if (!string.IsNullOrWhiteSpace(excludePatterns))
            {
                model.ExcludedPatterns.AddRange(excludePatterns.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries));
            }

            return(model);
        }
Beispiel #2
0
        private static void Initialize(FileSettings model)
        {
            // Included folders.
            model.IncludedFolders.Add(new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)));
            model.IncludedFolders.Add(new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)));
            model.IncludedFolders.Add(new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos)));
            model.IncludedFolders.Add(new DirectoryPath(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)));

            // Included extensions.
            model.IncludedExtensions.AddRange(new[]
            {
                "ai", "avi", "doc", "docx", "eps", "flv", "gif", "htm", "html",
                "jpeg", "jpg", "mov", "mp3", "mp4", "mpg", "mpeg", "odt", "ogg", "ogv", "pdf", "png", "ppt", "psd",
                "rar", "rtf", "svg", "txt", "wav", "wma", "xls", "xlsx", "zip"
            });

            // Excluded patterns.
            model.ExcludedPatterns.AddRange(new[] { ".git", "node_modules", "packages" });
        }