public object MapToEditConfig(ConfigInstance config, ConfigurationSetModel model) { var configModel = model.Configs.Single(s => s.Type == config.ConfigType); var source = config.GetConfiguration(); return(BuildObject(source, configModel.ConfigurationProperties)); }
/// <summary> /// Saves changes to configuration /// </summary> /// <param name="config">Updated configuration to be saved</param> /// <returns>A task that represents the asynchronous save operation.</returns> public async Task UpdateConfigAsync(ConfigInstance config) { var configId = config.ConfigType.Name; var configPath = GetCacheKey(configId, config.ClientId); var configText = JsonConvert.SerializeObject(config.GetConfiguration(), jsonSerializerSettings); await storageConnector.SetConfigFileAsync(configId, config.ClientId, configText); memoryCache.Set <string>(cachePrefix + configPath, configText, new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromMinutes(5))); }
public async Task Calls_Validator() { var config = new ConfigInstance <SampleConfig>(new SampleConfig(), command.Identity); configurationUpdatePayloadMapper.Setup(m => m.UpdateConfigurationInstance(It.IsAny <ConfigInstance>(), command.ConfigurationAsJson, It.IsAny <ConfigurationSetModel>())) .ReturnsAsync(() => config); var result = await target.Handle(command); validator.Verify(v => v.Validate(config.GetConfiguration(), model.Get <SampleConfig>(), command.Identity)); }
private ConfigStorageObject BuildStorageObject(ConfigInstance config) { return(new ConfigStorageObject { ServerVersion = config.ConfigurationIdentity.ServerVersion.ToString(), ClientId = config.ConfigurationIdentity.Client.ClientId, ConfigName = config.Name, TimeStamp = DateTime.UtcNow, Config = config.GetConfiguration() }); }
public object MapToEditConfig(ConfigInstance config, ConfigurationModel configModel) { var source = config.GetConfiguration(); return(BuildObject(source, configModel)); }