public FileNameHandler(UserPreferences.UserPreferences userPrefs) { var smallFileNameMakerRe = new Regex(@"\.(jpg|jpeg)$", RegexOptions.IgnoreCase); _filePattern = RegexFromPatternList(userPrefs.IncludeFiles); _excludePattern = string.IsNullOrWhiteSpace(userPrefs.ExcludeFolders) ? null : RegexFromPatternList(userPrefs.ExcludeFolders); _smallPattern = new Regex(@"\.small\.((jpeg)|(jpg))$", RegexOptions.Compiled | RegexOptions.IgnoreCase); _rightPattern = new Regex(@"\.right\.((jpeg)|(jpg))$", RegexOptions.Compiled | RegexOptions.IgnoreCase); _smallFileNameMaker = s => smallFileNameMakerRe.Replace(_largeFileNameMaker(s), ".small.$1"); _rightFileNameMaker = s => smallFileNameMakerRe.Replace(_largeFileNameMaker(s), ".right.$1"); _largeFileNameMaker = s => new Regex(@"(.*)\.(small|right)\.(jpg|jpeg)$", RegexOptions.IgnoreCase).Replace(s, "$1.$3"); }
public PersistedUserPreferences(bool forceRead) { if (forceRead || _userPreferences == null) { var file = new FileInfo(PrefFileName); // ReSharper disable once AssignNullToNotNullAttribute new DirectoryInfo(file.DirectoryName).Create(); if (!file.Exists) { return; } var reader = new StreamReader(PrefFileName); _userPreferences = reader.ReadToEnd().Deserialize <UserPreferences>(); reader.Close(); } CopyUserPreferences(_userPreferences, this); }