예제 #1
0
        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));
            }

            _logger.LogInformation("Saving ShellSettings for tenant '{0}'", shellSettings.Name);

            var tenantPath = _appDataFolder.MapPath(_appDataFolder.Combine("Sites", shellSettings.Name));

            var configurationSource = new DefaultFileConfigurationSource(
                _appDataFolder.Combine(tenantPath, string.Format(SettingsFileNameFormat, "txt")), false);

            foreach (var key in shellSettings.Keys)
            {
                configurationSource.Set(key, (shellSettings[key] ?? string.Empty).ToString());
            }

            configurationSource.Commit();

            _logger.LogInformation("Saved ShellSettings for tenant '{0}'", shellSettings.Name);
        }
예제 #2
0
        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));

            Logger.Information("Saving ShellSettings for tenant '{0}'", shellSettings.Name);

            var tenantPath = _appDataFolder.MapPath(_appDataFolder.Combine("Sites", shellSettings.Name));

            var configurationSource = new DefaultFileConfigurationSource(
                _appDataFolder.Combine(tenantPath, string.Format(SettingsFileNameFormat, "txt")), false);

            foreach (var key in shellSettings.Keys) {
                configurationSource.Set(key, (shellSettings[key] ?? string.Empty).ToString());
            }

            configurationSource.Commit();

            Logger.Information("Saved ShellSettings for tenant '{0}'", shellSettings.Name);
        }