Daniel's XL Toolbox NG
Bovender.UserSettings.UserSettingsBase Class Reference

Base class for persistent settings; a replacement for the UserSettings.UserSettingsBase system which has a couple of quirks and whose files are hard to find, read, and write by humans. More...

Inheritance diagram for Bovender.UserSettings.UserSettingsBase:

Public Member Functions

 UserSettingsBase ()
 
void Save ()
 Saves the user settings to a file. More...
 
virtual string GetSettingsFilePath ()
 Gets the complete path and file name for the user settings file. More...
 
 UserSettingsBase ()
 
void Save ()
 Saves the user settings to a file. More...
 
virtual string GetSettingsFilePath ()
 Gets the complete path and file name for the user settings file. More...
 

Static Public Member Functions

static void LoadDefaults ()
 Creates a new settings object without loading the saved settings from file and without saving the current settings from file. More...
 
static void LoadDefaults ()
 Creates a new settings object without loading the saved settings from file and without saving the current settings from file. More...
 

Protected Member Functions

virtual void WriteYamlHeader (StreamWriter streamWriter)
 Writes a header to the YAML file before all other data. To write comments, prefix lines with "#". More...
 
virtual void WriteYamlHeader (StreamWriter streamWriter)
 Writes a header to the YAML file before all other data. To write comments, prefix lines with "#". More...
 

Static Protected Member Functions

static T FromFileOrDefault< T > (string yamlFile)
 Loads options from a file, or creates a default instance if the I/O operation failed. This is a protected method. Implementations of UserSettingsBase must provide simple-access methods defined in IUserSettings to make life easier for the outside world. More...
 
static T FromFileOrDefault< T > (string yamlFile)
 Loads options from a file, or creates a default instance if the I/O operation failed. This is a protected method. Implementations of UserSettingsBase must provide simple-access methods defined in IUserSettings to make life easier for the outside world. More...
 

Properties

static UserSettingsBase Default [get, set]
 Gets the singleton instance of the user settings. Applications that use this framework may want to replace the default singleton with an instance of their own (UserSettingsBase.Default = myInstance), in order to avoid having two separate settings files, one for the Bovender framework and one for the application itself. More...
 
string User [get, set]
 
string Email [get, set]
 
bool CcUserOnExceptionReport [get, set]
 
string DownloadFolder [get, set]
 
bool WasFromFile [get, protected set]
 Is true if the options store was initially loaded from a YAML file. More...
 
Exception Exception [get, protected set]
 Gets the last IOException, if any occurred. More...
 

Detailed Description

Base class for persistent settings; a replacement for the UserSettings.UserSettingsBase system which has a couple of quirks and whose files are hard to find, read, and write by humans.

To make use of this options system, derive your own class from OptionsBase and add properties to it. These will be automatically saved to and loaded from a YAML file.

Constructor & Destructor Documentation

◆ UserSettingsBase() [1/2]

Bovender.UserSettings.UserSettingsBase.UserSettingsBase ( )
inline

◆ UserSettingsBase() [2/2]

Bovender.UserSettings.UserSettingsBase.UserSettingsBase ( )
inline

Member Function Documentation

◆ FromFileOrDefault< T >() [1/2]

static T Bovender.UserSettings.UserSettingsBase.FromFileOrDefault< T > ( string  yamlFile)
inlinestaticprotected

Loads options from a file, or creates a default instance if the I/O operation failed. This is a protected method. Implementations of UserSettingsBase must provide simple-access methods defined in IUserSettings to make life easier for the outside world.

Parameters
yamlFilePath to a YAML file that holds the options.
Template Parameters
TType of the OptionsStore derivative to load.
Returns
OptionsStore object, either with values loaded from file or with default values.
Type Constraints
T :UserSettingsBase 
T :new() 

◆ FromFileOrDefault< T >() [2/2]

static T Bovender.UserSettings.UserSettingsBase.FromFileOrDefault< T > ( string  yamlFile)
inlinestaticprotected

Loads options from a file, or creates a default instance if the I/O operation failed. This is a protected method. Implementations of UserSettingsBase must provide simple-access methods defined in IUserSettings to make life easier for the outside world.

Parameters
yamlFilePath to a YAML file that holds the options.
Template Parameters
TType of the OptionsStore derivative to load.
Returns
OptionsStore object, either with values loaded from file or with default values.
Type Constraints
T :UserSettingsBase 
T :new() 

◆ GetSettingsFilePath() [1/2]

virtual string Bovender.UserSettings.UserSettingsBase.GetSettingsFilePath ( )
inlinevirtual

Gets the complete path and file name for the user settings file.

Applications using this framework should override this.

Reimplemented in XLToolbox.UserSettings.UserSettings.

◆ GetSettingsFilePath() [2/2]

virtual string Bovender.UserSettings.UserSettingsBase.GetSettingsFilePath ( )
inlinevirtual

Gets the complete path and file name for the user settings file.

Applications using this framework should override this.

Reimplemented in XLToolbox.UserSettings.UserSettings.

◆ LoadDefaults() [1/2]

static void Bovender.UserSettings.UserSettingsBase.LoadDefaults ( )
inlinestatic

Creates a new settings object without loading the saved settings from file and without saving the current settings from file.

Derived classes should implement their own static variant of this method (which cannot be marked virtual because it is static), in order to generate an instance of the derived class, rather than an instance of UserSettingsBase.

◆ LoadDefaults() [2/2]

static void Bovender.UserSettings.UserSettingsBase.LoadDefaults ( )
inlinestatic

Creates a new settings object without loading the saved settings from file and without saving the current settings from file.

Derived classes should implement their own static variant of this method (which cannot be marked virtual because it is static), in order to generate an instance of the derived class, rather than an instance of UserSettingsBase.

◆ Save() [1/2]

void Bovender.UserSettings.UserSettingsBase.Save ( )
inline

Saves the user settings to a file.

◆ Save() [2/2]

void Bovender.UserSettings.UserSettingsBase.Save ( )
inline

Saves the user settings to a file.

◆ WriteYamlHeader() [1/2]

virtual void Bovender.UserSettings.UserSettingsBase.WriteYamlHeader ( StreamWriter  streamWriter)
inlineprotectedvirtual

Writes a header to the YAML file before all other data. To write comments, prefix lines with "#".

Reimplemented in XLToolbox.UserSettings.UserSettings.

◆ WriteYamlHeader() [2/2]

virtual void Bovender.UserSettings.UserSettingsBase.WriteYamlHeader ( StreamWriter  streamWriter)
inlineprotectedvirtual

Writes a header to the YAML file before all other data. To write comments, prefix lines with "#".

Reimplemented in XLToolbox.UserSettings.UserSettings.

Property Documentation

◆ CcUserOnExceptionReport

bool Bovender.UserSettings.UserSettingsBase.CcUserOnExceptionReport
getset

◆ Default

static UserSettingsBase Bovender.UserSettings.UserSettingsBase.Default
staticgetset

Gets the singleton instance of the user settings. Applications that use this framework may want to replace the default singleton with an instance of their own (UserSettingsBase.Default = myInstance), in order to avoid having two separate settings files, one for the Bovender framework and one for the application itself.

◆ DownloadFolder

string Bovender.UserSettings.UserSettingsBase.DownloadFolder
getset

◆ Email

string Bovender.UserSettings.UserSettingsBase.Email
getset

◆ Exception

Exception Bovender.UserSettings.UserSettingsBase.Exception
getprotected set

Gets the last IOException, if any occurred.

◆ User

string Bovender.UserSettings.UserSettingsBase.User
getset

◆ WasFromFile

bool Bovender.UserSettings.UserSettingsBase.WasFromFile
getprotected set

Is true if the options store was initially loaded from a YAML file.


The documentation for this class was generated from the following file: