File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed
Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,23 @@ protected SettingsBase(SettingsStore settings)
116116 /// </summary>
117117 public abstract void Reset ( ) ;
118118
119+ /// <summary>
120+ /// Change the settings store. Creates a new SettingsStore based on the provided parameters.
121+ /// See also SettingsStore.GetSettingStore().
122+ /// </summary>
123+ /// <param name="filePath">The path to the INI file, or NULL if using the registry.</param>
124+ /// <param name="registryKey">The registry key (name), or NULL if using an INI file. </param>
125+ /// <param name="section">Optional, the name of the section / subkey.</param>
126+ public virtual void ChangeSettingsStore ( string filePath , string registryKey , string section )
127+ {
128+ if ( SettingStore != null )
129+ {
130+ SettingStore . Discard ( ) ;
131+ SettingStore = null ;
132+ }
133+ SettingStore = SettingsStore . GetSettingStore ( filePath , registryKey , section ) ;
134+ }
135+
119136 /// <summary>
120137 /// Load settings from the options
121138 /// </summary>
Original file line number Diff line number Diff line change @@ -138,6 +138,15 @@ protected static void AssertGetUserValueType(Type expectedType)
138138 /// <param name="name">name of the setting</param>
139139 public abstract void DeleteUserValue ( string name ) ;
140140
141+ /// <summary>
142+ /// Discard the settings store.
143+ /// Performs actions (if any) to close the settings store so that a new one can be used.
144+ /// </summary>
145+ public virtual void Discard ( )
146+ {
147+ // default action is to do nothing. Concrete classes may override.
148+ }
149+
141150 /// <summary>
142151 /// Factory method to create a setting store (sub-class of SettingsStore)
143152 /// </summary>
@@ -308,6 +317,19 @@ public override void DeleteUserValue(string name)
308317 {
309318 Key . DeleteValue ( name , false ) ;
310319 }
320+
321+ /// <summary>
322+ /// Discard the settings store.
323+ /// Close the registry key.
324+ /// </summary>
325+ public override void Discard ( )
326+ {
327+ if ( Key != null )
328+ {
329+ Key . Close ( ) ;
330+ // cannot set to null, as Key (and string version) are readonly
331+ }
332+ }
311333 }
312334
313335 /// <summary>
Original file line number Diff line number Diff line change @@ -585,6 +585,22 @@ public override void Reset()
585585 Reset ( property . Name ) ;
586586 }
587587
588+ /// <summary>
589+ /// Change the settings store for the user settings and its sub-settings.
590+ /// Creates a new SettingsStore based on the provided parameters.
591+ /// </summary>
592+ /// <param name="filePath">The path to the INI file, or NULL if using the registry.</param>
593+ /// <param name="registryKey">The registry key (name), or NULL if using an INI file. </param>
594+ /// <param name="section">Optional, the name of the section / subkey.</param>
595+ public override void ChangeSettingsStore ( string filePath , string registryKey , string section )
596+ {
597+ base . ChangeSettingsStore ( filePath , registryKey , section ) ;
598+ Folders . ChangeSettingsStore ( filePath , registryKey , section ) ;
599+ Input . ChangeSettingsStore ( filePath , registryKey , section ) ;
600+ RailDriver . ChangeSettingsStore ( filePath , registryKey , section ) ;
601+ Content . ChangeSettingsStore ( filePath , registryKey , section ) ;
602+ }
603+
588604 public void Log ( )
589605 {
590606 foreach ( var property in GetProperties ( ) . OrderBy ( p => p . Name ) )
You can’t perform that action at this time.
0 commit comments