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

Preferences for the application. More...

Inheritance diagram for BogaNet.Prefs.Preferences:
BogaNet.Util.Singleton< Preferences > BogaNet.Prefs.IFilePreferences BogaNet.Prefs.IPreferences

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 string GetString (string key, bool obfuscated=false)
 Get a string for a key.
 
virtual bool TryGetString (string key, out string result, bool obfuscated=false)
 Tries to get a string for a key.
 
virtual T GetObject< T > (string key, bool obfuscated=false)
 Get an object for a key.
 
virtual bool TryGetObject< T > (string key, out T result, bool obfuscated=false)
 Tries to get an object for a key.
 
virtual T GetNumber< T > (string key, bool obfuscated=false)
 Get a number for a key.
 
virtual bool TryGetNumber< T > (string key, out T result, bool obfuscated=false)
 Tries to get a number for a key.
 
virtual bool GetBool (string key, bool obfuscated=false)
 Get a bool for a key.
 
virtual bool TryGetBool (string key, out bool result, bool obfuscated=false)
 Tries to get a bool for a key.
 
virtual DateTime GetDate (string key, bool obfuscated=false, TimeZoneInfo? usedTZ=null)
 Get a DateTime for a key.
 
virtual bool TryGetDate (string key, out DateTime result, bool obfuscated=false, TimeZoneInfo? usedTZ=null)
 Tries to get a DateTime for a key.
 
virtual void Set (string key, string value, bool obfuscated=false)
 Set a string for a key.
 
virtual void Set (string key, object value, bool obfuscated=false)
 Set an object for a key.
 
virtual void Set< T > (string key, T value, bool obfuscated=false)
 Set a number for a key.
 
virtual void Set (string key, bool value, bool obfuscated=false)
 Set a bool for a key.
 
virtual void Set (string key, DateTime value, bool obfuscated=false)
 Set a DateTime for a key.
 
- Public Member Functions inherited from BogaNet.Prefs.IFilePreferences
delegate void FileLoaded (string file)
 Delegate for the load status of the file.
 
delegate void FileSaved (string file)
 Delegate for the save status of the file.
 

Protected Member Functions

 Preferences ()
 

Properties

virtual ByteObf IV [set]
 IV for the obfuscated data.
 
virtual IPreferencesContainer Container = new PreferencesContainer() [get, set]
 
virtual bool AutoSaveOnExit = true [get, set]
 Store the data automatically at application exit.
 
virtual bool IsLoaded [get]
 Are the preferences loaded?
 
bool IsSaved [get]
 Are the current preferences 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.Util.Singleton< Preferences >
static T Instance [get]
 
- Properties inherited from BogaNet.Prefs.IFilePreferences
- Properties inherited from BogaNet.Prefs.IPreferences

Events

IFilePreferences.? FileLoaded OnFileLoaded
 
IFilePreferences.? FileSaved OnFileSaved
 
- Events inherited from BogaNet.Prefs.IFilePreferences
FileLoaded OnFileLoaded
 Event triggered whenever the file is loaded.
 
FileSaved OnFileSaved
 Event triggered whenever the file is saved.
 

Detailed Description

Preferences for the application.

Constructor & Destructor Documentation

◆ Preferences()

BogaNet.Prefs.Preferences.Preferences ( )
protected

Member Function Documentation

◆ ContainsKey()

virtual bool BogaNet.Prefs.Preferences.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.IPreferences.

◆ Delete()

virtual bool BogaNet.Prefs.Preferences.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.IFilePreferences.

◆ GetBool()

virtual bool BogaNet.Prefs.Preferences.GetBool ( string key,
bool obfuscated = false )
virtual

Get a bool for a key.

Parameters
keyKey for the bol.
obfuscatedObfuscate value in the preferences (optional, default: false)
Returns
Bool for the key
Exceptions
ArgumentNullException

Implements BogaNet.Prefs.IPreferences.

◆ GetDate()

virtual DateTime BogaNet.Prefs.Preferences.GetDate ( string key,
bool obfuscated = false,
TimeZoneInfo? usedTZ = null )
virtual

Get a DateTime for a key.

Parameters
keyKey for the DateTime.
obfuscatedObfuscate value in the preferences (optional, default: false)
usedTZTime zone of the date (optional, default: local)
Returns
DateTime for the key
Exceptions
ArgumentNullException

Implements BogaNet.Prefs.IPreferences.

◆ GetNumber< T >()

virtual T BogaNet.Prefs.Preferences.GetNumber< T > ( string key,
bool obfuscated = false )
virtual

Get a number for a key.

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

Implements BogaNet.Prefs.IPreferences.

Type Constraints
T :INumber<T> 

◆ GetObject< T >()

virtual T BogaNet.Prefs.Preferences.GetObject< T > ( 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.IPreferences.

◆ GetString()

virtual string BogaNet.Prefs.Preferences.GetString ( string key,
bool obfuscated = false )
virtual

Get a string for a key.

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

Implements BogaNet.Prefs.IPreferences.

◆ Load()

virtual bool BogaNet.Prefs.Preferences.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.IFilePreferences.

◆ LoadAsync()

virtual async Task< bool > BogaNet.Prefs.Preferences.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.IFilePreferences.

◆ Remove()

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

Removes a key/value from the preferences.

Parameters
keyKey (and value) to delete
Exceptions
ArgumentNullException

Implements BogaNet.Prefs.IPreferences.

◆ Save()

virtual bool BogaNet.Prefs.Preferences.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.IFilePreferences.

◆ SaveAsync()

virtual async Task< bool > BogaNet.Prefs.Preferences.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.IFilePreferences.

◆ Set() [1/4]

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

Set a bool for a key.

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

Implements BogaNet.Prefs.IPreferences.

◆ Set() [2/4]

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

Set a DateTime for a key.

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

Implements BogaNet.Prefs.IPreferences.

◆ Set() [3/4]

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

Set an object for a key.

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

Implements BogaNet.Prefs.IPreferences.

◆ Set() [4/4]

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

Set a string for a key.

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

Implements BogaNet.Prefs.IPreferences.

◆ Set< T >()

virtual void BogaNet.Prefs.Preferences.Set< T > ( string key,
T value,
bool obfuscated = false )
virtual

Set a number for a key.

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

Implements BogaNet.Prefs.IPreferences.

Type Constraints
T :INumber<T> 

◆ TryGetBool()

virtual bool BogaNet.Prefs.Preferences.TryGetBool ( string key,
out bool result,
bool obfuscated = false )
virtual

Tries to get a bool for a key.

Parameters
keyKey for the bol.
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.IPreferences.

◆ TryGetDate()

virtual bool BogaNet.Prefs.Preferences.TryGetDate ( string key,
out DateTime result,
bool obfuscated = false,
TimeZoneInfo? usedTZ = null )
virtual

Tries to get a DateTime for a key.

Parameters
keyKey for the DateTime.
resultout parameter for the result
obfuscatedObfuscate value in the preferences (optional, default: false)
usedTZTime zone of the date (optional, default: local)
Returns
True if the operation was successful
Exceptions
ArgumentNullException

Implements BogaNet.Prefs.IPreferences.

◆ TryGetNumber< T >()

virtual bool BogaNet.Prefs.Preferences.TryGetNumber< T > ( string key,
out T result,
bool obfuscated = false )
virtual

Tries to get a number for a key.

Parameters
keyKey for the number
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.IPreferences.

Type Constraints
T :INumber<T> 

◆ TryGetObject< T >()

virtual bool BogaNet.Prefs.Preferences.TryGetObject< T > ( string key,
out T 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.IPreferences.

◆ TryGetString()

virtual bool BogaNet.Prefs.Preferences.TryGetString ( string key,
out string result,
bool obfuscated = false )
virtual

Tries to get a string for a key.

Parameters
keyKey for the string
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.IPreferences.

Property Documentation

◆ AutoSaveOnExit

virtual bool BogaNet.Prefs.Preferences.AutoSaveOnExit = true
getset

Store the data automatically at application exit.

Implements BogaNet.Prefs.IFilePreferences.

◆ Container

virtual IPreferencesContainer BogaNet.Prefs.Preferences.Container = new PreferencesContainer()
getset

◆ Count

virtual int BogaNet.Prefs.Preferences.Count
get

Current count of keys from the preferences.

Implements BogaNet.Prefs.IPreferences.

◆ IsLoaded

virtual bool BogaNet.Prefs.Preferences.IsLoaded
get

Are the preferences loaded?

Implements BogaNet.Prefs.IPreferences.

◆ IsSaved

bool BogaNet.Prefs.Preferences.IsSaved
get

Are the current preferences saved?

Implements BogaNet.Prefs.IPreferences.

◆ IV

virtual ByteObf BogaNet.Prefs.Preferences.IV
set

IV for the obfuscated data.

Implements BogaNet.Prefs.IPreferences.

◆ Keys

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

Current keys of the preferences.

Implements BogaNet.Prefs.IPreferences.

Event Documentation

◆ OnFileLoaded

IFilePreferences.? FileLoaded BogaNet.Prefs.Preferences.OnFileLoaded

◆ OnFileSaved

IFilePreferences.? FileSaved BogaNet.Prefs.Preferences.OnFileSaved

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