private void SaveAndUpdateCache(IgnoreFile ignoreFile, string path, bool overwrite) { if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentException(nameof(path)); } if (ignoreFile == null) { throw new ArgumentException(nameof(ignoreFile)); } if (File.Exists(path) && overwrite == false) { throw new InvalidOperationException("File already exists and overwrite is not specified as true!"); } if (Path.GetExtension(path).ToLower() != _extension) { throw new InvalidOperationException("Extension \".repignore\" has to be specified!"); } using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None)) { _formatter.Serialize(fs, ignoreFile); } AddOrUpdate(path, _ignoreFiles, ignoreFile); AddOrUpdate(path, _ignoreFilesChanged, true); }
public void Save(IgnoreFile ignoreFile, string path, bool overwrite = false) { SaveAndUpdateCache(ignoreFile, path, overwrite); }