public void SaveToSource(string name, IDictionary <string, string> configuration) { var settingsFile = GetSettingsFilePath(Path.Combine( _optionsAccessor.Value.ShellsApplicationDataPath, _optionsAccessor.Value.ShellsContainerName, name)); var configurationProvider = new YamlConfigurationProvider(new YamlConfigurationSource { Path = settingsFile, Optional = false }); configurationProvider.Set(name, null); configurationProvider.Set($"{name}:RequestUrlHost", ObtainValue(configuration, $"{name}:RequestUrlHost")); configurationProvider.Set($"{name}:RequestUrlPrefix", ObtainValue(configuration, $"{name}:RequestUrlPrefix")); configurationProvider.Set($"{name}:DatabaseProvider", ObtainValue(configuration, $"{name}:DatabaseProvider")); configurationProvider.Set($"{name}:TablePrefix", ObtainValue(configuration, $"{name}:TablePrefix")); configurationProvider.Set($"{name}:ConnectionString", ObtainValue(configuration, $"{name}:ConnectionString")); configurationProvider.Set($"{name}:State", ObtainValue(configuration, $"{name}:State")); configurationProvider.Set($"{name}:Secret", ObtainValue(configuration, $"{name}:Secret")); configurationProvider.Set($"{name}:RecipeName", ObtainValue(configuration, $"{name}:RecipeName")); configurationProvider.Commit(); }
void IShellSettingsManager.SaveSettings(ShellSettings shellSettings) { if (shellSettings == null) { throw new ArgumentNullException(nameof(shellSettings)); } if (string.IsNullOrWhiteSpace(shellSettings.Name)) { throw new ArgumentException( "The Name property of the supplied ShellSettings object is null or empty; the settings cannot be saved.", nameof(shellSettings.Name)); } if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Saving ShellSettings for tenant '{0}'", shellSettings.Name); } var tenantPath = _appDataFolder.MapPath(_appDataFolder.Combine("Sites", shellSettings.Name)); var configurationProvider = new YamlConfigurationProvider( _appDataFolder.Combine(tenantPath, string.Format(SettingsFileNameFormat, "txt")), false); foreach (var key in shellSettings.RootConfiguration.GetChildren()) { configurationProvider.Set(key.Key, key.Value); } configurationProvider.Commit(); if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Saved ShellSettings for tenant '{0}'", shellSettings.Name); } }
void IShellSettingsManager.SaveSettings(ShellSettings shellSettings) { Argument.ThrowIfNull(shellSettings, nameof(shellSettings)); Argument.ThrowIfNullOrWhiteSpace(shellSettings.Name, nameof(shellSettings.Name), "The Name property of the supplied ShellSettings object is null or empty; the settings cannot be saved."); if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Saving ShellSettings for tenant '{0}'", shellSettings.Name); } var tenantPath = _appDataFolder.MapPath( _appDataFolder.Combine( _optionsAccessor.Value.Location, shellSettings.Name, string.Format(SettingsFileNameFormat, "txt"))); var configurationProvider = new YamlConfigurationProvider(tenantPath, false); foreach (var key in shellSettings.Keys) { if (!string.IsNullOrEmpty(shellSettings[key])) { configurationProvider.Set(key, shellSettings[key]); } } configurationProvider.Commit(); if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Saved ShellSettings for tenant '{0}'", shellSettings.Name); } }
public ICommandResult <IThemeDescriptor> UpdateTheme( string pathToThemeFolder, IThemeDescriptor descriptor) { if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (string.IsNullOrEmpty(descriptor.Name)) { throw new ArgumentNullException(nameof(descriptor.Name)); } // Path to theme manifest file var fileName = string.Format(ByThemeFileNameFormat, "txt"); var manifestPath = _platoFileSystem.MapPath( _platoFileSystem.Combine(pathToThemeFolder, fileName)); // Configure YAML configuration var configurationProvider = new YamlConfigurationProvider(new YamlConfigurationSource { Path = manifestPath, Optional = false }); // Build configuration foreach (var key in descriptor.Keys) { if (!string.IsNullOrEmpty(descriptor[key])) { configurationProvider.Set(key, descriptor[key]); } } var result = new CommandResult <ThemeDescriptor>(); try { configurationProvider.Commit(); } catch (Exception e) { return(result.Failed(e.Message)); } return(result.Success(descriptor)); }
public bool SaveSettings(IShellSettings shellSettings) { if (shellSettings == null) { throw new ArgumentNullException(nameof(shellSettings)); } if (string.IsNullOrEmpty(shellSettings.Name)) { throw new ArgumentNullException(nameof(shellSettings.Name)); } if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Saving shell settings for tenant '{0}'", shellSettings.Name); } var fileName = string.Format(SettingsFileNameFormat, "txt"); var tenantPath = _appDataFolder.MapPath( _appDataFolder.Combine( _optionsAccessor.Value.Location, shellSettings.Location, fileName)); var configurationProvider = new YamlConfigurationProvider(new YamlConfigurationSource { Path = tenantPath, Optional = false }); foreach (var key in shellSettings.Keys) { if (!string.IsNullOrEmpty(shellSettings[key])) { configurationProvider.Set(key, shellSettings[key]); } } configurationProvider.Commit(); if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Saved shell settings for tenant '{0}'", shellSettings.Name); } return(true); }
void IShellSettingsManager.SaveSettings(ShellSettings shellSettings) { if (shellSettings == null) { throw new ArgumentNullException(nameof(shellSettings)); } if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Saving ShellSettings for tenant '{0}'", shellSettings.Name); } var tenantPath = Path.Combine( _hostingEnvironment.ContentRootPath, _optionsAccessor.Value.ShellsRootContainerName, _optionsAccessor.Value.ShellsContainerName, shellSettings.Name, string.Format(SettingsFileNameFormat, "txt")); var configurationProvider = new YamlConfigurationProvider(new YamlConfigurationSource { Path = tenantPath, Optional = false }); foreach (var key in shellSettings.Keys) { if (!string.IsNullOrEmpty(shellSettings[key])) { configurationProvider.Set(key, shellSettings[key]); } } configurationProvider.Commit(); if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Saved ShellSettings for tenant '{0}'", shellSettings.Name); } }
void IShellSettingsManager.SaveSettings(ShellSettings shellSettings) { Argument.ThrowIfNull(shellSettings, nameof(shellSettings)); Argument.ThrowIfNullOrWhiteSpace(shellSettings.Name, nameof(shellSettings.Name), "The Name property of the supplied ShellSettings object is null or empty; the settings cannot be saved."); if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Saving ShellSettings for tenant '{0}'", shellSettings.Name); } var tenantPath = Path.Combine( _hostingEnvironment.ContentRootPath, _optionsAccessor.Value.ShellsRootContainerName, _optionsAccessor.Value.ShellsContainerName, shellSettings.Name, string.Format(SettingsFileNameFormat, "txt")); var configurationProvider = new YamlConfigurationProvider(new YamlConfigurationSource { Path = tenantPath, Optional = false }); foreach (var key in shellSettings.Keys) { if (!string.IsNullOrEmpty(shellSettings[key])) { configurationProvider.Set(key, shellSettings[key]); } } configurationProvider.Commit(); if (_logger.IsEnabled(LogLevel.Information)) { _logger.LogInformation("Saved ShellSettings for tenant '{0}'", shellSettings.Name); } }