/// <summary> /// Constructor /// </summary> /// <param name="service">Service</param> /// <param name="modifier">Config modifier</param> /// <param name="modifiedConfig">Receives modified config</param> public TempConfigChanger(IConfigReaderWriter config, Func <string, string> modifier, out string modifiedConfig) { this.config = config; origConfig = config.ReadConfigAsync().Sync(); this.modifiedConfig = modifiedConfig = modifier(origConfig); config.WriteConfigAsync(this.modifiedConfig).Sync(); if (config is IIPBanService service) { service.RunCycleAsync().Sync(); } }
/// <summary> /// Revert config back to original value /// </summary> public void Dispose() { config.WriteConfigAsync(origConfig).Sync(); }
/// <summary> /// Revert config back to original value /// </summary> public void Dispose() { GC.SuppressFinalize(this); config.WriteConfigAsync(origConfig).Sync(); }