private void BtNew_Click(object sender, RoutedEventArgs e) { FileExclusions.Clear(); DataContext = null; Globals.Settings = new SchedulerSettings.Settings(); DataContext = Globals.Settings; Logger.Log($"User '{Environment.UserName}' Loaded default settings.", LogType.Info); }
private bool IsExclusion(string file) { var fileInfo = new FileInfo(file); if (!(fileInfo.Length > 0 && fileInfo.Length <= MaxSize)) { FileDetails fileDetails = CommonUtility.CreateFileDetails(file, Runner, Logger, EnvironmentInfo); if (null != fileDetails) { FileExclusions.Add(fileDetails); } return(true); } return(false); }
public virtual void Validate() { char[] invalid = Path.GetInvalidFileNameChars(); if (FileInclusions.Any(ext => ext.Any(c => invalid.Contains(c)))) { throw new ArgumentException("One or more file extensions are not valid"); } if (MinSize < 0) { throw new ArgumentException("The minimum file size must be a positive number"); } if (MaxSize <= MinSize) { throw new ArgumentException("The maximum size must be greater than the minimum size"); } if (string.IsNullOrEmpty(SourceDirectory) && !SourceDirectoryCurrent) { throw new ArgumentException("The source directory can't be empty"); } if (SourceDirectoryCurrent && !string.IsNullOrEmpty(SourceDirectory)) { throw new ArgumentException("The --source-current and --source options can't be used at the same time"); } if (!string.IsNullOrEmpty(SourceDirectory)) { invalid = Path.GetInvalidPathChars(); if (SourceDirectory.Any(c => invalid.Contains(c))) { throw new ArgumentException("The source directory isn't valid"); } if (!Directory.Exists(SourceDirectory)) { throw new ArgumentException("The source directory doesn't exist"); } } if (FileInclusions.Any() && FileExclusions.Any()) { throw new ArgumentException("The list of extensions to exclude must be empty when other extensions to look for are specified"); } if (Preset.HasValue && (FileInclusions.Any() || FileExclusions.Any())) { throw new ArgumentException("The preset option cannot be used with --include or --exclude"); } }
private void BtOpen_Click(object sender, RoutedEventArgs e) { var d = new OpenFileDialog { Filter = "Settings files (*.xml)|*.xml", }; if (d.ShowDialog() == true) { try { Globals.Settings = SettingsUtils.GetSettingsFromFile(d.FileName); DataContext = Globals.Settings; _fileName = d.FileName; FileExclusions.Clear(); var filetext = string.Empty; foreach (var file in Globals.Settings.RestartChecks.PendingFileNameExclusions) { if (!string.IsNullOrEmpty(file)) { filetext += file + Environment.NewLine; } } if (!string.IsNullOrEmpty(filetext)) { FileExclusions.Text = filetext.TrimEnd(Environment.NewLine.ToCharArray()); } Logger.Log($"User '{Environment.UserName}' Opened settings file '{_fileName}'", LogType.Info); } catch (Exception ex) { Logger.Log($"Failed to load file '{_fileName}', Exception: '{ex.Message}'", LogType.Error); } } }
private void Lw_SettingsLoaded(object sender, EventArguments.LoadEventArg e) { var obj = SettingsUtils.StringToSettings <SchedulerSettings.Settings>(e.Settings); DataContext = null; Globals.Settings = obj; DataContext = Globals.Settings; FileExclusions.Clear(); var filetext = string.Empty; foreach (var file in Globals.Settings.RestartChecks.PendingFileNameExclusions) { if (!string.IsNullOrEmpty(file)) { filetext += file + Environment.NewLine; } } if (!string.IsNullOrEmpty(filetext)) { FileExclusions.Text = filetext.TrimEnd(Environment.NewLine.ToCharArray()); } }
public void Validate() { char[] invalid = Path.GetInvalidFileNameChars(); if (FileInclusions.Any(ext => ext.Any(c => invalid.Contains(c)) || ext.Contains('.'))) { throw new ArgumentException("One or more file extensions are not valid"); } if (FileExclusions.Any(ext => ext.Any(c => invalid.Contains(c)) || ext.Contains('.'))) { throw new ArgumentException("One or more file extensions are not valid"); } invalid = Path.GetInvalidPathChars(); if (DirExclusions.Any(ext => ext.Contains(Path.DirectorySeparatorChar) || ext.Any(c => invalid.Contains(c)))) { throw new ArgumentException("One or more dir exclusions are not valid"); } if (!string.IsNullOrEmpty(Id) && (Id.Contains(Path.DirectorySeparatorChar) || Id.Any(c => invalid.Contains(c)))) { throw new ArgumentException("The backup id is not valid"); } if (MaxSize <= 100) { throw new ArgumentException("The maximum size must be at least 100KB"); } if (string.IsNullOrEmpty(SourceDirectory) && !SourceDirectoryCurrent) { throw new ArgumentException("The source directory can't be empty"); } if (SourceDirectoryCurrent && !string.IsNullOrEmpty(SourceDirectory)) { throw new ArgumentException("The --source-current and --source options can't be used at the same time"); } if (!string.IsNullOrEmpty(SourceDirectory)) { invalid = Path.GetInvalidPathChars(); if (SourceDirectory.Any(c => invalid.Contains(c))) { throw new ArgumentException("The source directory isn't valid"); } if (!Directory.Exists(SourceDirectory)) { throw new ArgumentException("The source directory doesn't exist"); } } if (!Directory.Exists(TargetDirectory)) { throw new ArgumentException("The target directory doesn't exist"); } if (FileInclusions.Any() && FileExclusions.Any()) { throw new ArgumentException("The list of extensions to exclude must be empty when other extensions to look for are specified"); } if (Preset != ExtensionsPreset.None && (FileInclusions.Any() || FileExclusions.Any())) { throw new ArgumentException("The preset option cannot be used with --include or --exclude"); } if (Threads == 0 || Threads < -1) { throw new ArgumentException("Invalid number of threads"); } if (Multithread && Threads == 1) { throw new ArgumentException("Do you really want to multithread with just a single thread?"); } }
public StoryTestSuite(FileExclusions exclusions, Func <string, bool> contentFilter) { this.exclusions = exclusions; this.contentFilter = contentFilter; }
public Filters(string tagList, FileExclusions fileExclusions, string selection) { this.tagList = tagList; this.fileExclusions = fileExclusions; this.selection = selection; }