API documentation, members, signatures, and C# examples.
Search the framework
Find classes, members, and documentation.
NamespaceWealthLab.Core
Parent
Object
SettingsManager manages a collection of string-keyed settings and persists them to a local file. It supports several common data types, optional file encryption, throttled disk writes, and thread-safe access through internal locking.
Creates a SettingsManager that loads and saves settings using the specified fileName.
If the file already exists, its contents are loaded into the SettingsManager.
When encrypt is true, each persisted entry is decrypted when loading and encrypted when saving.
A typical location for a settings file can be based on WLHost.Instance.DataFolder.
Returns the value associated with key, converted to the requested type.
If key does not exist, the supplied default value is returned.
Supported types are:
string
bool
int
double
DateTime
WLColor
Double values are parsed using invariant culture.
DateTime values are persisted internally using their Ticks value.
WLColor values are restored using WLColor.Parse.
Sets the value associated with key.
Supported types are:
string
bool
int
double
DateTime
WLColor
Calling Set marks the SettingsManager as requiring a save and attempts to persist the settings according to SaveThrottleSeconds.
Double values are persisted using invariant culture.
DateTime values are stored using their Ticks value.
WLColor values are stored using their string representation.
Forces all SettingsManager instances created during the current application session to save any pending changes.
This method is intended for application shutdown so that settings still waiting because of save throttling are written to disk.
Returns true if the SettingsManager contains the specified key.
The comparison is case-insensitive.
Returns false if key is null, empty, or contains only whitespace.
Removes the setting associated with key.
Null or empty keys are ignored.
After removing the entry, the SettingsManager marks its contents for saving and attempts to save according to SaveThrottleSeconds.
Attempts to save the current settings to disk.
When fromSet is true, the SettingsManager marks itself as requiring a save.
If no save is required, the method returns without writing the file. If a save is required but the interval specified by SaveThrottleSeconds has not elapsed since the previous save, the write is deferred until a later call.
When a save occurs, settings are written as sorted key=value lines.
If IsEncrypted is true, each line is encrypted before being written.
Gets or sets the minimum number of seconds between automatic writes to disk.
The default value is 1.
Calling Set or Remove marks the SettingsManager as needing to save, but repeated changes made within the throttle interval can be combined into a later disk write rather than causing a write for every change.
Need help with this API?
Ask the community or explore custom development services.