/// <summary> /// Saves the configuration object to a file. /// </summary> /// <param name="softwareConfig"></param> public void Save <T>(T softwareConfig) where T : SoftwareConfig { var xml = softwareConfig.SerializeXML(); xml.Save(FilePath); OnConfigurationChanged?.Invoke(this, new EventArgs()); }
public async Task LoadAsync(ConfiguratorPaths paths, CancellationToken token) { Current = await LoadConfigurationAsync(paths); _currentWatcher = Watch(paths.WorkspacePath, async() => { OnConfigurationChanged?.Invoke(this, new ConfigurationChangedArgs(await LoadConfigurationAsync(paths))); }); }
private async Task RefreshLogicAsync(object sender) { this.log.Debug($"RefreshLogic start [{sender}]"); var latestConfig = this.configCache.Get(); var newConfig = await this.configFetcher.Fetch(latestConfig); if (!latestConfig.Equals(newConfig)) { this.log.Debug("config changed"); this.configCache.Set(newConfig); OnConfigurationChanged?.Invoke(this, OnConfigurationChangedEventArgs.Empty); } }
//Enables PubSub via a redis server public async Task Subscribe() { if (_isSubscribing && _connectionMultiplexer.IsConnected) { return; } _isSubscribing = true; EnsureRedisConnection(_settings); await _subscriber.SubscribeAsync(Constants.RedisPubSubChannel, (channel, value) => { if (value.HasValue) { //Notify update via an event OnConfigurationChanged?.Invoke(value.ToString()); } }); }
private async Task RefreshLogicAsync(object sender) { this.log.Debug($"RefreshLogic start [{sender}]"); var latestConfig = await this.configCache.GetAsync(base.cacheKey).ConfigureAwait(false); var newConfig = await this.configFetcher.Fetch(latestConfig).ConfigureAwait(false); if (!latestConfig.Equals(newConfig) && !newConfig.Equals(ProjectConfig.Empty)) { this.log.Debug("config changed"); await this.configCache.SetAsync(base.cacheKey, newConfig).ConfigureAwait(false); OnConfigurationChanged?.Invoke(this, OnConfigurationChangedEventArgs.Empty); initializedEventSlim.Set(); } }