Skip to content

Commit

Permalink
Merge pull request #4052 from ahoefling/host_settings_dictionary
Browse files Browse the repository at this point in the history
Updated IHostSettingsService to use IDictionary instead of Dictionary
  • Loading branch information
valadas authored Sep 5, 2020
2 parents 4173b94 + ea10342 commit 9ed0f16
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ public interface IHostSettingsService
/// Gets all host settings.
/// </summary>
/// <returns>host setting.</returns>
Dictionary<string, IConfigurationSetting> GetSettings();
IDictionary<string, IConfigurationSetting> GetSettings();

/// <summary>
/// Gets all host settings as dictionary.
/// </summary>
/// <returns>host setting's value.</returns>
Dictionary<string, string> GetSettingsDictionary();
IDictionary<string, string> GetSettingsDictionary();

/// <summary>
/// Gets the setting value by the specific key.
Expand Down Expand Up @@ -140,7 +140,7 @@ public interface IHostSettingsService
/// Updates the specified settings.
/// </summary>
/// <param name="settings">The settings.</param>
void Update(Dictionary<string, string> settings);
void Update(IDictionary<string, string> settings);

/// <summary>
/// Updates the setting for a specified key.
Expand Down
9 changes: 5 additions & 4 deletions DNN Platform/Library/Entities/Controllers/HostController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public int GetInteger(string key, int defaultValue)
}

/// <inheritdoc/>
Dictionary<string, IConfigurationSetting> IHostSettingsService.GetSettings()
IDictionary<string, IConfigurationSetting> IHostSettingsService.GetSettings()
{
return CBO.GetCachedObject<Dictionary<string, IConfigurationSetting>>(
new CacheItemArgs(
Expand All @@ -128,9 +128,10 @@ Dictionary<string, IConfigurationSetting> IHostSettingsService.GetSettings()
}

/// <inheritdoc/>
public Dictionary<string, string> GetSettingsDictionary()
IDictionary<string, string> IHostSettingsService.GetSettingsDictionary()
{
return this.GetSettings().ToDictionary(c => c.Key, c => c.Value.Value);
return ((IHostSettingsService)this).GetSettings()
.ToDictionary(c => c.Key, c => c.Value.Value);
}

/// <inheritdoc/>
Expand Down Expand Up @@ -162,7 +163,7 @@ public string GetString(string key, string defaultValue)
}

/// <inheritdoc/>
public void Update(Dictionary<string, string> settings)
void IHostSettingsService.Update(IDictionary<string, string> settings)
{
foreach (KeyValuePair<string, string> settingKvp in settings)
{
Expand Down
10 changes: 9 additions & 1 deletion DNN Platform/Library/Obsolete/HostController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ public partial class HostController : ComponentBase<IHostController, HostControl
}
}

/// <inheritdoc/>
[Obsolete("Deprecated in 9.7.1. Scheduled for removal in v11.0.0, use DotNetNuke.Abstractions.IHostSettingsService instead.")]
public Dictionary<string, ConfigurationSetting> GetSettings() =>
((IHostSettingsService)this).GetSettings()
.Where(setting => setting.Value is ConfigurationSetting)
.Select(setting => new KeyValuePair<string, ConfigurationSetting>(setting.Key, (ConfigurationSetting)setting.Value))
.ToDictionary(setting => setting.Key, setting => setting.Value);

[Obsolete("Deprecated in 9.7.1. Scheduled for removal in v11.0.0, use DotNetNuke.Abstractions.IHostSettingsService instead.")]
public Dictionary<string, string> GetSettingsDictionary() =>
((IHostSettingsService)this).GetSettingsDictionary()
.ToDictionary(setting => setting.Key, setting => setting.Value);

/// <inheritdoc/>
[Obsolete("Deprecated in 9.7.1. Scheduled for removal in v11.0.0, use DotNetNuke.Abstractions.IHostSettingsService instead.")]
public void Update(ConfigurationSetting config) =>
Expand All @@ -49,5 +53,9 @@ public void Update(ConfigurationSetting config) =>
[Obsolete("Deprecated in 9.7.1. Scheduled for removal in v11.0.0, use DotNetNuke.Abstractions.IHostSettingsService instead.")]
public void Update(ConfigurationSetting config, bool clearCache) =>
((IHostSettingsService)this).Update(config, clearCache);

[Obsolete("Deprecated in 9.7.1. Scheduled for removal in v11.0.0, use DotNetNuke.Abstractions.IHostSettingsService instead.")]
public void Update(Dictionary<string, string> settings) =>
((IHostSettingsService)this).Update(settings);
}
}

0 comments on commit 9ed0f16

Please sign in to comment.