C# Class Habanero.DB.DatabaseSettings

Stores database settings as a cache and updates or retrieves settings either from the cache or from the database if the cache value has expired
Inheritance: System.MarshalByRefObject, ISettings
Mostrar archivo Open project: Chillisoft/habanero Class Usage Examples

Public Methods

Method Description
DatabaseSettings ( IDatabaseConnection databaseConnection ) : System

Constructor to initialise an empty store of settings, using the table name of "settings"

DatabaseSettings ( string tableName, IDatabaseConnection databaseConnection ) : System

Constructor to initialise an empty store of settings, specifying the table name to use to store the settings

GetBoolean ( string settingName ) : bool

Returns a specified setting as a boolean

GetDecimal ( string settingName ) : decimal

Returns the configuration for the setting name provided

GetDecimal ( string settingName, System.DateTime date ) : decimal

Returns a specified setting as a decimal

GetString ( string settingName ) : string

Returns a specified setting as a string

GetString ( string settingName, System.DateTime date ) : string

Returns a specified setting as a string

HasSetting ( string settingName ) : bool

Returns whether the setting exists or not.

SetBoolean ( string settingName, bool boolValue ) : void

Sets a specified setting as a boolean

SetDecimal ( string settingName, decimal settingValue ) : void

Sets a setting with a decimal value (using the InvariantCulture). Uses DateTime.Now for the date of the setting to indicate when the setting was changed.

SetString ( string settingName, string settingValue ) : void

Sets a specified setting as a string

Private Methods

Method Description
CreateInsertStatement ( string settingName, string settingValue ) : SqlStatement

Creates a sql insert statement from the name and value provided

CreateSelectStatement ( string settingName, System.DateTime date ) : SqlStatement

Creates a sql select statement to retrieve the named setting at the date specified

CreateUpdateStatementNoDate ( string settingName, string settingValue ) : SqlStatement

Creates a sql update statement from the name and value provided, with no date specified

GetValue ( string settingName, System.DateTime date ) : object

Retrieves the named setting with the date specified, either from the cache or from the database if the cached value has expired

RetrieveSettingValue ( string settingName, System.DateTime date, object &value ) : bool
SetValue ( string settingName, string settingValue ) : void

Updates the named setting in the database with the value specified

UpdateCache ( string settingName ) : void

Refreshes the cached setting stored in this instance, by retrieving the updated setting from the database

Method Details

DatabaseSettings() public method

Constructor to initialise an empty store of settings, using the table name of "settings"
public DatabaseSettings ( IDatabaseConnection databaseConnection ) : System
databaseConnection IDatabaseConnection
return System

DatabaseSettings() public method

Constructor to initialise an empty store of settings, specifying the table name to use to store the settings
public DatabaseSettings ( string tableName, IDatabaseConnection databaseConnection ) : System
tableName string The table name in which to store settings
databaseConnection IDatabaseConnection
return System

GetBoolean() public method

Returns a specified setting as a boolean
public GetBoolean ( string settingName ) : bool
settingName string The setting name
return bool

GetDecimal() public method

Returns the configuration for the setting name provided
public GetDecimal ( string settingName ) : decimal
settingName string The setting name
return decimal

GetDecimal() public method

Returns a specified setting as a decimal
public GetDecimal ( string settingName, System.DateTime date ) : decimal
settingName string The setting name
date System.DateTime The date at which to check the setting
return decimal

GetString() public method

Returns a specified setting as a string
public GetString ( string settingName ) : string
settingName string The setting name
return string

GetString() public method

Returns a specified setting as a string
public GetString ( string settingName, System.DateTime date ) : string
settingName string The setting name
date System.DateTime The date of the setting to retrieve /// (ie this method will retrieve the setting value as at this date
return string

HasSetting() public method

Returns whether the setting exists or not.
public HasSetting ( string settingName ) : bool
settingName string The name of the setting to look for.
return bool

SetBoolean() public method

Sets a specified setting as a boolean
public SetBoolean ( string settingName, bool boolValue ) : void
settingName string The setting name
boolValue bool The value to set it to
return void

SetDecimal() public method

Sets a setting with a decimal value (using the InvariantCulture). Uses DateTime.Now for the date of the setting to indicate when the setting was changed.
public SetDecimal ( string settingName, decimal settingValue ) : void
settingName string The name of the setting to set
settingValue decimal The value to set the setting to.
return void

SetString() public method

Sets a specified setting as a string
public SetString ( string settingName, string settingValue ) : void
settingName string The setting name
settingValue string The value to set it to
return void