Add GetSetting shims

This commit is contained in:
Bepis committed 2019-11-07 21:13:24 +11:00
1 parent cce2d32db0
commit c5759cdccf
1 file changed
+34 -3
+34 -3
View File
@@ -185,6 +185,37 @@ namespace BepInEx.Configuration
#region Wraps
/// <summary>
/// Access one of the existing settings. If the setting has not been added yet, null is returned.
/// If the setting exists but has a different type than T, an exception is thrown.
/// New settings should be added with <see cref="AddSetting{T}(ConfigDefinition,T,ConfigDescription)"/>.
/// </summary>
/// <typeparam name="T">Type of the value contained in this setting.</typeparam>
/// <param name="configDefinition">Section and Key of the setting.</param>
[Obsolete("Use ConfigFile[key] or TryGetEntry instead")]
public ConfigEntry<T> GetSetting<T>(ConfigDefinition configDefinition)
{
return TryGetEntry<T>(configDefinition, out var entry)
? entry
: null;
}
/// <summary>
/// Access one of the existing settings. If the setting has not been added yet, null is returned.
/// If the setting exists but has a different type than T, an exception is thrown.
/// New settings should be added with <see cref="AddSetting{T}(ConfigDefinition,T,ConfigDescription)"/>.
/// </summary>
/// <typeparam name="T">Type of the value contained in this setting.</typeparam>
/// <param name="section">Section/category/group of the setting. Settings are grouped by this.</param>
/// <param name="key">Name of the setting.</param>
[Obsolete("Use ConfigFile[key] or TryGetEntry instead")]
public ConfigEntry<T> GetSetting<T>(string section, string key)
{
return TryGetEntry<T>(section, key, out var entry)
? entry
: null;
}
/// <summary>
/// Access one of the existing settings. If the setting has not been added yet, false is returned. Otherwise, true.
/// If the setting exists but has a different type than T, an exception is thrown.
@@ -289,7 +320,7 @@ namespace BepInEx.Configuration
/// <param name="configDefinition">Section and Key of the setting.</param>
/// <param name="defaultValue">Value of the setting if the setting was not created yet.</param>
/// <param name="configDescription">Description of the setting shown to the user and other metadata.</param>
[Obsolete("Use bind instead")]
[Obsolete("Use Bind instead")]
public ConfigEntry<T> AddSetting<T>(ConfigDefinition configDefinition, T defaultValue, ConfigDescription configDescription = null)
=> Bind(configDefinition, defaultValue, configDescription);
@@ -302,7 +333,7 @@ namespace BepInEx.Configuration
/// <param name="key">Name of the setting.</param>
/// <param name="defaultValue">Value of the setting if the setting was not created yet.</param>
/// <param name="configDescription">Description of the setting shown to the user and other metadata.</param>
[Obsolete("Use bind instead")]
[Obsolete("Use Bind instead")]
public ConfigEntry<T> AddSetting<T>(string section, string key, T defaultValue, ConfigDescription configDescription = null)
=> Bind(new ConfigDefinition(section, key), defaultValue, configDescription);
@@ -315,7 +346,7 @@ namespace BepInEx.Configuration
/// <param name="key">Name of the setting.</param>
/// <param name="defaultValue">Value of the setting if the setting was not created yet.</param>
/// <param name="description">Simple description of the setting shown to the user.</param>
[Obsolete("Use bind instead")]
[Obsolete("Use Bind instead")]
public ConfigEntry<T> AddSetting<T>(string section, string key, T defaultValue, string description)
=> Bind(new ConfigDefinition(section, key), defaultValue, new ConfigDescription(description));