Browse Source

Add additional config shims

Bepis 5 years ago
parent
commit
2947805cb8
1 changed files with 52 additions and 2 deletions
  1. 52 2
      BepInEx/Configuration/ConfigFile.cs

+ 52 - 2
BepInEx/Configuration/ConfigFile.cs

@@ -39,6 +39,18 @@ namespace BepInEx.Configuration
 				}
 			}
 		}
+		
+		/// <summary>
+		/// Create an array with all config entries inside of this config file. Should be only used for metadata purposes.
+		/// If you want to access and modify an existing setting then use <see cref="AddSetting{T}(ConfigDefinition,T,ConfigDescription)"/> 
+		/// instead with no description.
+		/// </summary>
+		[Obsolete("Use Values instead")]
+		public ConfigEntryBase[] GetConfigEntries()
+		{
+			lock (_ioLock)
+				return Entries.Values.ToArray();
+		}
 
 		/// <summary>
 		/// Full path to the config file. The file might not exist until a setting is added and changed, or <see cref="Save"/> is called.
@@ -269,8 +281,46 @@ namespace BepInEx.Configuration
 		public ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description)
 			=> Bind(new ConfigDefinition(section, key), defaultValue, new ConfigDescription(description));
 
+		/// <summary>
+		/// Create a new setting. The setting is saved to drive and loaded automatically.
+		/// Each definition can be used to add only one setting, trying to add a second setting will throw an exception.
+		/// </summary>
+		/// <typeparam name="T">Type of the value contained in this setting.</typeparam>
+		/// <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")]
+		public ConfigEntry<T> AddSetting<T>(ConfigDefinition configDefinition, T defaultValue, ConfigDescription configDescription = null)
+			=> Bind(configDefinition, defaultValue, configDescription);
+
+		/// <summary>
+		/// Create a new setting. The setting is saved to drive and loaded automatically.
+		/// Each section and key pair can be used to add only one setting, trying to add a second setting will throw an exception.
+		/// </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>
+		/// <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")]
+		public ConfigEntry<T> AddSetting<T>(string section, string key, T defaultValue, ConfigDescription configDescription = null)
+			=> Bind(new ConfigDefinition(section, key), defaultValue, configDescription);
+
+		/// <summary>
+		/// Create a new setting. The setting is saved to drive and loaded automatically.
+		/// Each section and key pair can be used to add only one setting, trying to add a second setting will throw an exception.
+		/// </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>
+		/// <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")]
+		public ConfigEntry<T> AddSetting<T>(string section, string key, T defaultValue, string description)
+			=> Bind(new ConfigDefinition(section, key), defaultValue, new ConfigDescription(description));
+
         /// <summary>
-        /// Access a setting. Use Bind and GetSetting instead.
+        /// Access a setting. Use Bind instead.
         /// </summary>
         [Obsolete("Use Bind instead")]
 		public ConfigWrapper<T> Wrap<T>(string section, string key, string description = null, T defaultValue = default(T))
@@ -284,7 +334,7 @@ namespace BepInEx.Configuration
 		}
 
 		/// <summary>
-		/// Access a setting. Use Bind and GetSetting instead.
+		/// Access a setting. Use Bind instead.
 		/// </summary>
 		[Obsolete("Use Bind instead")]
 		public ConfigWrapper<T> Wrap<T>(ConfigDefinition configDefinition, T defaultValue = default(T))