Click or drag to resize

Config Class

Provide an access to the configuration.

Inheritance Hierarchy
SystemObject
  AskiaPortalCmn.ConfigurationConfig

Namespace:  AskiaPortalCmn.Configuration
Assembly:  AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax
public class Config : IConfig, IEnumerable<IConfigItem>, 
	IEnumerable

The Config type exposes the following members.

Properties
  NameDescription
Public propertyStatic memberEnvironmentMode
Current environment mode
Public propertyCode exampleItemConfigKey
Get the configuration item in the `askiaportal` namespace
Public propertyCode exampleItemString, NullableGuid
Get the configuration item of the specified module.
Public propertyMainDatabase
Get the connection of the main SQL database
Public propertyRootPath
Get the root path of the configuration directory
Public propertyStatic memberSqlLocalDbInstanceName
Instance name of the SQLLocalDB for the tests
Public propertyTestDatabase
Get or set the connection of the test SQL database
Public propertyTestLicensesKey
Get the licenses key for the unit tests.
Top
Methods
  NameDescription
Public methodApplyRecordedChanges
Save configuration item that has been changed since the initialization, and reload the configuration in order to make the changes visible.
Public methodCode exampleContains
Indicates if the specified item is contains in the configuration of the specified module.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodFindAllReferences(ValueReference, Guid)
Get the list of configuration item that refers to the specified item.
Public methodFindAllReferences(ValueReference, Int32)
Get the list of configuration item that refers to the specified item.
Public methodStatic memberGetConfigFileContent
Read the configuration file and return his content in dictionary format
Public methodGetEnumerator
Returns an enumerator that iterates through the collection.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodStatic memberGetInstance
Get the single instance of the configuration
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRecordChange(IContext, ConfigKey, Boolean)
Record a new value for the specified configuration item.
It will not apply the change in the configuration, nor save in the database unless you explicitly call the ApplyRecordedChanges(IContext) method.
Public methodRecordChange(IContext, ConfigKey, Double)
Record a new value for the specified configuration item.
It will not apply the change in the configuration, nor save in the database unless you explicitly call the ApplyRecordedChanges(IContext) method.
Public methodRecordChange(IContext, ConfigKey, Guid)
Record a new value for the specified configuration item.
It will not apply the change in the configuration, nor save in the database unless you explicitly call the ApplyRecordedChanges(IContext) method.
Public methodRecordChange(IContext, ConfigKey, Int32)
Record a new value for the specified configuration item.
It will not apply the change in the configuration, nor save in the database unless you explicitly call the ApplyRecordedChanges(IContext) method.
Public methodRecordChange(IContext, ConfigKey, String)
Record a new value for the specified configuration item.
It will not apply the change in the configuration, nor save in the database unless you explicitly call the ApplyRecordedChanges(IContext) method.
Public methodRecordChange(IContext, String, Boolean, NullableGuid)
Record a new value for the specified configuration item.
It will not apply the change in the configuration, nor save in the database unless you explicitly call the ApplyRecordedChanges(IContext) method.
Public methodRecordChange(IContext, String, Double, NullableGuid)
Record a new value for the specified configuration item.
It will not apply the change in the configuration, nor save in the database unless you explicitly call the ApplyRecordedChanges(IContext) method.
Public methodRecordChange(IContext, String, Guid, NullableGuid)
Record a new value for the specified configuration item.
It will not apply the change in the configuration, nor save in the database unless you explicitly call the ApplyRecordedChanges(IContext) method.
Public methodRecordChange(IContext, String, Int32, NullableGuid)
Record a new value for the specified configuration item.
It will not apply the change in the configuration, nor save in the database unless you explicitly call the ApplyRecordedChanges(IContext) method.
Public methodRecordChange(IContext, String, String, NullableGuid)
Record a new value for the specified configuration item.
It will not apply the change in the configuration, nor save in the database unless you explicitly call the ApplyRecordedChanges(IContext) method.
Public methodReload
Reload the configuration using the current database values.
Public methodStatic memberSetEnvironment
Indicates which environment is currently used.
Public methodStatic memberSetTestDatabase
Override the connection string of the test database
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodStatic memberUseSqlLocalDbForTests
Usage of the SQLLocalDB for the Test environment. https://docs.microsoft.com/en-us/sql/tools/sqllocaldb-utility
Top
Remarks

Singleton object, use the GetInstance to instantiate it.

It open the AskiaPortal.config store in ProgramData\AskiaPortal folder.

Examples

The content of the config file should looks like this:

<configuration version="1.0"><askiaportalcmn><settings key="mainDatabase" value="Data Source=[SERVER];Initial Catalog=AskiaPortal;Persist Security Info=True;User ID=[USER_ID];Password=[PASSWORD];" /></askiaportalcmn></configuration>
Examples

Basic usage:

using AskiaPortalCmn.Configuration;

// ...
var config = Config.GetInstance();
Console.WriteLine("The path of the AskiaPortal configuration directory is `{0}`", config.RootPath);
Console.WriteLine("The connection string of the main database (AskiaPortal) is `{0}`", config.MainDatabase);
See Also