66namespace ReClassNET . Util
77{
88 /// <summary>
9- /// A class which stores custom config items from plugins.
10- /// The id of an item should consist of "a-zA-z0-9.,;_-+".
11- /// The naming convention is "Plugin.[ConfigGroup.]ConfigItem ".
9+ /// A class which stores custom data items from plugins.
10+ /// The key to an item should consist of "a-zA-z0-9.,;_-+".
11+ /// The naming convention for keys is "PluginName.[Group.]Item ".
1212 /// </summary>
13- public class CustomConfig
13+ public class CustomDataMap
1414 {
1515 private readonly Dictionary < string , string > data = new Dictionary < string , string > ( ) ;
1616
@@ -30,95 +30,95 @@ internal void Deserialize(XElement element)
3030 /// <summary>
3131 /// Sets a configuration item.
3232 /// </summary>
33- /// <param name="id ">The id of the item.</param>
33+ /// <param name="key ">The key of the item.</param>
3434 /// <param name="value">
3535 /// The value of the item.
3636 /// If the value is null the item gets removed.
3737 /// </param>
38- public void SetString ( string id , string value )
38+ public void SetString ( string key , string value )
3939 {
40- if ( id == null )
40+ if ( key == null )
4141 {
42- throw new ArgumentNullException ( nameof ( id ) ) ;
42+ throw new ArgumentNullException ( nameof ( key ) ) ;
4343 }
44- if ( id . Length == 0 )
44+ if ( key . Length == 0 )
4545 {
4646 throw new ArgumentException ( ) ;
4747 }
4848
4949 if ( value == null )
5050 {
51- data . Remove ( id ) ;
51+ data . Remove ( key ) ;
5252 }
5353 else
5454 {
55- data [ id ] = value ;
55+ data [ key ] = value ;
5656 }
5757 }
5858
5959 /// <summary>
6060 /// Sets a configuration item.
6161 /// </summary>
62- /// <param name="id ">The id of the item.</param>
62+ /// <param name="key ">The key of the item.</param>
6363 /// <param name="value">The value of the item.</param>
64- public void SetBool ( string id , bool value )
64+ public void SetBool ( string key , bool value )
6565 {
66- SetString ( id , Convert . ToString ( value ) ) ;
66+ SetString ( key , Convert . ToString ( value ) ) ;
6767 }
6868
6969 /// <summary>
7070 /// Sets a configuration item.
7171 /// </summary>
72- /// <param name="id ">The id of the item.</param>
72+ /// <param name="key ">The key of the item.</param>
7373 /// <param name="value">The value of the item.</param>
74- public void SetLong ( string id , long value )
74+ public void SetLong ( string key , long value )
7575 {
76- SetString ( id , value . ToString ( NumberFormatInfo . InvariantInfo ) ) ;
76+ SetString ( key , value . ToString ( NumberFormatInfo . InvariantInfo ) ) ;
7777 }
7878
7979 /// <summary>
8080 /// Sets a configuration item.
8181 /// </summary>
82- /// <param name="id ">The id of the item.</param>
82+ /// <param name="key ">The key of the item.</param>
8383 /// <param name="value">The value of the item.</param>
84- public void SetULong ( string id , ulong value )
84+ public void SetULong ( string key , ulong value )
8585 {
86- SetString ( id , value . ToString ( NumberFormatInfo . InvariantInfo ) ) ;
86+ SetString ( key , value . ToString ( NumberFormatInfo . InvariantInfo ) ) ;
8787 }
8888
89- public void SetXElement ( string id , XElement value )
89+ public void SetXElement ( string key , XElement value )
9090 {
91- SetString ( id , value . ToString ( ) ) ;
91+ SetString ( key , value . ToString ( ) ) ;
9292 }
9393
9494 /// <summary>
9595 /// Gets the value of the config item.
9696 /// </summary>
97- /// <param name="id ">The id of the item.</param>
98- /// <returns>The value of the config item or null if the id does not exists.</returns>
99- public string GetString ( string id )
97+ /// <param name="key ">The key of the item.</param>
98+ /// <returns>The value of the config item or null if the key does not exists.</returns>
99+ public string GetString ( string key )
100100 {
101- return GetString ( id , null ) ;
101+ return GetString ( key , null ) ;
102102 }
103103
104104 /// <summary>
105105 /// Gets the value of the config item.
106106 /// </summary>
107- /// <param name="id ">The id of the item.</param>
108- /// <param name="def">The default value if the id does not exists.</param>
109- /// <returns>The value of the config item or <paramref name="def"/> if the id does not exists.</returns>
110- public string GetString ( string id , string def )
107+ /// <param name="key ">The key of the item.</param>
108+ /// <param name="def">The default value if the key does not exists.</param>
109+ /// <returns>The value of the config item or <paramref name="def"/> if the key does not exists.</returns>
110+ public string GetString ( string key , string def )
111111 {
112- if ( id == null )
112+ if ( key == null )
113113 {
114- throw new ArgumentNullException ( nameof ( id ) ) ;
114+ throw new ArgumentNullException ( nameof ( key ) ) ;
115115 }
116- if ( id . Length == 0 )
116+ if ( key . Length == 0 )
117117 {
118118 throw new ArgumentException ( ) ;
119119 }
120120
121- if ( data . TryGetValue ( id , out var value ) )
121+ if ( data . TryGetValue ( key , out var value ) )
122122 {
123123 return value ;
124124 }
@@ -129,12 +129,12 @@ public string GetString(string id, string def)
129129 /// <summary>
130130 /// Gets the value of the config item.
131131 /// </summary>
132- /// <param name="id ">The id of the item.</param>
133- /// <param name="def">The default value if the id does not exists.</param>
134- /// <returns>The value of the config item or <paramref name="def"/> if the id does not exists.</returns>
135- public bool GetBool ( string id , bool def )
132+ /// <param name="key ">The key of the item.</param>
133+ /// <param name="def">The default value if the key does not exists.</param>
134+ /// <returns>The value of the config item or <paramref name="def"/> if the key does not exists.</returns>
135+ public bool GetBool ( string key , bool def )
136136 {
137- var value = GetString ( id , null ) ;
137+ var value = GetString ( key , null ) ;
138138 if ( string . IsNullOrEmpty ( value ) )
139139 {
140140 return def ;
@@ -146,12 +146,12 @@ public bool GetBool(string id, bool def)
146146 /// <summary>
147147 /// Gets the value of the config item.
148148 /// </summary>
149- /// <param name="id ">The id of the item.</param>
150- /// <param name="def">The default value if the id does not exists.</param>
151- /// <returns>The value of the config item or <paramref name="def"/> if the id does not exists.</returns>
152- public long GetLong ( string id , long def )
149+ /// <param name="key ">The key of the item.</param>
150+ /// <param name="def">The default value if the key does not exists.</param>
151+ /// <returns>The value of the config item or <paramref name="def"/> if the key does not exists.</returns>
152+ public long GetLong ( string key , long def )
153153 {
154- var str = GetString ( id , null ) ;
154+ var str = GetString ( key , null ) ;
155155 if ( string . IsNullOrEmpty ( str ) )
156156 {
157157 return def ;
@@ -168,12 +168,12 @@ public long GetLong(string id, long def)
168168 /// <summary>
169169 /// Gets the value of the config item.
170170 /// </summary>
171- /// <param name="id ">The id of the item.</param>
172- /// <param name="def">The default value if the id does not exists.</param>
173- /// <returns>The value of the config item or <paramref name="def"/> if the id does not exists.</returns>
174- public ulong GetULong ( string id , ulong def )
171+ /// <param name="key ">The key of the item.</param>
172+ /// <param name="def">The default value if the key does not exists.</param>
173+ /// <returns>The value of the config item or <paramref name="def"/> if the key does not exists.</returns>
174+ public ulong GetULong ( string key , ulong def )
175175 {
176- var str = GetString ( id , null ) ;
176+ var str = GetString ( key , null ) ;
177177 if ( string . IsNullOrEmpty ( str ) )
178178 {
179179 return def ;
@@ -190,12 +190,12 @@ public ulong GetULong(string id, ulong def)
190190 /// <summary>
191191 /// Gets the value of the config item.
192192 /// </summary>
193- /// <param name="id ">The id of the item.</param>
194- /// <param name="def">The default value if the id does not exists.</param>
195- /// <returns>The value of the config item or <paramref name="def"/> if the id does not exists.</returns>
196- public XElement GetXElement ( string id , XElement def )
193+ /// <param name="key ">The key of the item.</param>
194+ /// <param name="def">The default value if the key does not exists.</param>
195+ /// <returns>The value of the config item or <paramref name="def"/> if the key does not exists.</returns>
196+ public XElement GetXElement ( string key , XElement def )
197197 {
198- var str = GetString ( id , null ) ;
198+ var str = GetString ( key , null ) ;
199199 if ( string . IsNullOrEmpty ( str ) )
200200 {
201201 return def ;
0 commit comments