BogaNet 1.4.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Properties | Events | List of all members
BogaNet.Prefs.PreferencesContainer Class Reference

Container for the application preferences. More...

Inheritance diagram for BogaNet.Prefs.PreferencesContainer:
BogaNet.Prefs.IPreferencesContainer BogaNet.Prefs.BrowserPreferencesContainer

Public Member Functions

virtual bool Load (string filepath="")
 Load the preference file.
 
virtual async Task< bool > LoadAsync (string filepath="")
 Load the preference file asynchronously.
 
virtual bool Save (string filepath="")
 Save the preference file.
 
virtual async Task< bool > SaveAsync (string filepath="")
 Save the preference file asynchronously.
 
virtual bool Delete (string filepath="")
 Delete all preferences, including the file.
 
virtual bool Remove (string key)
 Removes a key/value from the preferences.
 
virtual bool ContainsKey (string key)
 Checks if a given key exists in the preferences.
 
virtual object Get (string key, bool obfuscated=false)
 Get an object for a key.
 
virtual bool TryGet (string key, out object result, bool obfuscated=false)
 Tries to get an object for a key.
 
virtual void Set (string key, object value, bool obfuscated=false)
 Set an object for a key.
 
override string ToString ()
 

Protected Attributes

string _file = "BNPrefs.json"
 
Dictionary< string, object > _preferences = []
 

Properties

virtual ByteObf IV = 139 [set]
 IV for the obfuscated data.
 
virtual bool IsLoaded [get, protected set]
 Is the preferences-container loaded?
 
virtual bool IsSaved [get, protected set]
 Is the current preferences-container saved?
 
virtual List< string > Keys [get]
 Current keys of the preferences.
 
virtual int Count [get]
 Current count of keys from the preferences.
 
- Properties inherited from BogaNet.Prefs.IPreferencesContainer

Events

IFilePreferences.? FileLoaded OnFileLoaded
 
IFilePreferences.? FileSaved OnFileSaved
 

Detailed Description

Container for the application preferences.

Member Function Documentation

◆ ContainsKey()

virtual bool BogaNet.Prefs.PreferencesContainer.ContainsKey ( string key)
virtual

Checks if a given key exists in the preferences.

Parameters
keyKey to check
Returns
True if the key exists in the preferences
Exceptions
ArgumentNullException

Implements BogaNet.Prefs.IPreferencesContainer.

◆ Delete()

virtual bool BogaNet.Prefs.PreferencesContainer.Delete ( string filepath = "")
virtual

Delete all preferences, including the file.

Parameters
filepathPreference file to delete

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.Prefs.IPreferencesContainer.

Reimplemented in BogaNet.Prefs.BrowserPreferencesContainer.

◆ Get()

virtual object BogaNet.Prefs.PreferencesContainer.Get ( string key,
bool obfuscated = false )
virtual

Get an object for a key.

Parameters
keyKey for the object
obfuscatedObfuscate value in the preferences (optional, default: false)
Returns
Object for the key
Exceptions
ArgumentNullException

Implements BogaNet.Prefs.IPreferencesContainer.

◆ Load()

virtual bool BogaNet.Prefs.PreferencesContainer.Load ( string filepath = "")
virtual

Load the preference file.

Parameters
filepathPreference file to load

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.Prefs.IPreferencesContainer.

Reimplemented in BogaNet.Prefs.BrowserPreferencesContainer.

◆ LoadAsync()

virtual async Task< bool > BogaNet.Prefs.PreferencesContainer.LoadAsync ( string filepath = "")
virtual

Load the preference file asynchronously.

Parameters
filepathPreference file to load

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.Prefs.IPreferencesContainer.

Reimplemented in BogaNet.Prefs.BrowserPreferencesContainer.

◆ Remove()

virtual bool BogaNet.Prefs.PreferencesContainer.Remove ( string key)
virtual

Removes a key/value from the preferences.

Parameters
keyKey (and value) to delete

returns>True if the operation was successful

Exceptions
ArgumentNullException

Implements BogaNet.Prefs.IPreferencesContainer.

◆ Save()

virtual bool BogaNet.Prefs.PreferencesContainer.Save ( string filepath = "")
virtual

Save the preference file.

Parameters
filepathPreference file to save

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.Prefs.IPreferencesContainer.

Reimplemented in BogaNet.Prefs.BrowserPreferencesContainer.

◆ SaveAsync()

virtual async Task< bool > BogaNet.Prefs.PreferencesContainer.SaveAsync ( string filepath = "")
virtual

Save the preference file asynchronously.

Parameters
filepathPreference file to save

returns>True if the operation was successful

Exceptions
Exception

Implements BogaNet.Prefs.IPreferencesContainer.

Reimplemented in BogaNet.Prefs.BrowserPreferencesContainer.

◆ Set()

virtual void BogaNet.Prefs.PreferencesContainer.Set ( string key,
object value,
bool obfuscated = false )
virtual

Set an object for a key.

Parameters
keyKey for the string
valueObject for the preferences
obfuscatedObfuscate value in the preferences (optional, default: false)
Exceptions
ArgumentNullException

Implements BogaNet.Prefs.IPreferencesContainer.

◆ ToString()

override string BogaNet.Prefs.PreferencesContainer.ToString ( )

◆ TryGet()

virtual bool BogaNet.Prefs.PreferencesContainer.TryGet ( string key,
out object result,
bool obfuscated = false )
virtual

Tries to get an object for a key.

Parameters
keyKey for the object
resultout parameter for the result
obfuscatedObfuscate value in the preferences (optional, default: false)
Returns
True if the operation was successful
Exceptions
ArgumentNullException

Implements BogaNet.Prefs.IPreferencesContainer.

Member Data Documentation

◆ _file

string BogaNet.Prefs.PreferencesContainer._file = "BNPrefs.json"
protected

◆ _preferences

Dictionary<string, object> BogaNet.Prefs.PreferencesContainer._preferences = []
protected

Property Documentation

◆ Count

virtual int BogaNet.Prefs.PreferencesContainer.Count
get

Current count of keys from the preferences.

Implements BogaNet.Prefs.IPreferencesContainer.

◆ IsLoaded

virtual bool BogaNet.Prefs.PreferencesContainer.IsLoaded
getprotected set

Is the preferences-container loaded?

Implements BogaNet.Prefs.IPreferencesContainer.

◆ IsSaved

virtual bool BogaNet.Prefs.PreferencesContainer.IsSaved
getprotected set

Is the current preferences-container saved?

Implements BogaNet.Prefs.IPreferencesContainer.

◆ IV

virtual ByteObf BogaNet.Prefs.PreferencesContainer.IV = 139
set

IV for the obfuscated data.

Implements BogaNet.Prefs.IPreferencesContainer.

◆ Keys

virtual List<string> BogaNet.Prefs.PreferencesContainer.Keys
get

Current keys of the preferences.

Implements BogaNet.Prefs.IPreferencesContainer.

Event Documentation

◆ OnFileLoaded

IFilePreferences.? FileLoaded BogaNet.Prefs.PreferencesContainer.OnFileLoaded

◆ OnFileSaved

IFilePreferences.? FileSaved BogaNet.Prefs.PreferencesContainer.OnFileSaved

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