public Task Set(string file, string key, string value, CancellationToken token) { file.VerifyNotEmpty(nameof(file)); key.VerifyNotEmpty(nameof(key)); value.VerifyNotEmpty(nameof(value)); using IDisposable scope = _logger.BeginScope(new { Command = nameof(Set), File = file, Key = key, Value = value }); PropertyFile db = PropertyFile.ReadFromFile(file, true); db.Properties[key] = value; db.WriteToFile(); _logger.LogInformation($"Set property {key}={value} from database {db.File}..."); return(Task.CompletedTask); }
public Task Delete(string file, string key, CancellationToken token) { file.VerifyNotEmpty(nameof(file)); key.VerifyNotEmpty(nameof(key)); using IDisposable scope = _logger.BeginScope(new { Command = nameof(Delete), File = file, Key = key }); PropertyFile db = PropertyFile.ReadFromFile(file, true); _logger.LogInformation($"Delete property {key} from database {file}..."); bool removed = db.Properties.Remove(key); if (removed) { db.WriteToFile(file); } _logger.LogInformation($"Property {(removed ? "was removed" : "was not found")}"); return(Task.CompletedTask); }