Class ConfigFile
Utility class used to access the SuperOffice entry in the Config file.
Inherited Members
Namespace: SuperOffice.Configuration
Assembly: SoCore.dll
Syntax
public static class ConfigFile
Remarks
IMPORTANT:
Avoid reading directly from configurationfile like this;_values = (NameValueCollection)ConfigurationSettings.GetConfig("SuperOffice/Security/Sentry");
Instead use this;
_values = (NameValueCollection)ConfigFile.GetConfig("SuperOffice/Diagnostics");
This enables the code to check for missing configuration files, and missing xml sections, thus, enabling the code to throw appropriate exceptions.
Properties
IsOnline
Return true if this config is set up for SuperOffice Online: appSettings/IsOnline = true
Declaration
public static bool IsOnline { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Also checks appSettings/ConfigServiceBaseUrl and appSettings/PublicApiUrl for URL-ish values if the Online value cannot be found.
Methods
AddOverride(string, string, string)
Set an override for a Config file value. All such overrides should be made before the first call to SoSession.Authenticate, as later calls may not be honoured (no retroactive effects!).
Declaration
public static bool AddOverride(string path, string name, string value)
Parameters
Type | Name | Description |
---|---|---|
string | path | Path of config item, such as 'SuperOffice/Data/Database' |
string | name | Name of value to be overridden, such as 'Server' |
string | value | Value to substitute over the config file value, such as 'myTestServer' |
Returns
Type | Description |
---|---|
bool | true if there was already an override for this path/name combination, false if not. The last call to AddOverride wins! |
Remarks
IMPORTANT:
Avoid reading directly from configurationfile like this;_values = (NameValueCollection)ConfigurationSettings.GetConfig("SuperOffice/Security/Sentry");
Instead use this;
_values = (NameValueCollection)ConfigFile.GetConfig("SuperOffice/Diagnostics");
This enables the code to check for missing configuration files, and missing xml sections, thus, enabling the code to throw appropriate exceptions.
AddOverrides(string[,])
Add multiple overrides in one batch. The last call to AddOverride wins!
Declaration
public static bool AddOverrides(string[,] overrides)
Parameters
Type | Name | Description |
---|---|---|
string[,] | overrides | Multi-dimensional array of overrides: (("path", "key", "val"),("path2", "key2", "val2"), etc) |
Returns
Type | Description |
---|---|
bool | True if there was already an override for one of the path/name combinations, false if not. |
Remarks
IMPORTANT:
Avoid reading directly from configurationfile like this;_values = (NameValueCollection)ConfigurationSettings.GetConfig("SuperOffice/Security/Sentry");
Instead use this;
_values = (NameValueCollection)ConfigFile.GetConfig("SuperOffice/Diagnostics");
This enables the code to check for missing configuration files, and missing xml sections, thus, enabling the code to throw appropriate exceptions.
ForceOverrideIsOnline(bool)
WARNING: Test-only method. This method is only meant to be used within unit-tests which needs to check online-specific behaviour.
Invoking this function should never be done from regular, production code.
Event in tests, using this method directly is not really recommended, but instead one should use the TemporaryOnlineState helper-class.
Declaration
public static void ForceOverrideIsOnline(bool isOnline)
Parameters
Type | Name | Description |
---|---|---|
bool | isOnline |
Remarks
IMPORTANT:
Avoid reading directly from configurationfile like this;_values = (NameValueCollection)ConfigurationSettings.GetConfig("SuperOffice/Security/Sentry");
Instead use this;
_values = (NameValueCollection)ConfigFile.GetConfig("SuperOffice/Diagnostics");
This enables the code to check for missing configuration files, and missing xml sections, thus, enabling the code to throw appropriate exceptions.
GetAllOverrides()
Get all overrides added to config as multi-dimensional string array.
Declaration
public static string[,] GetAllOverrides()
Returns
Type | Description |
---|---|
string[,] | string multi-dimensional array: (("path/to/key", "name", "value"),("path/to/key", "name2", "value2")) |
Remarks
IMPORTANT:
Avoid reading directly from configurationfile like this;_values = (NameValueCollection)ConfigurationSettings.GetConfig("SuperOffice/Security/Sentry");
Instead use this;
_values = (NameValueCollection)ConfigFile.GetConfig("SuperOffice/Diagnostics");
This enables the code to check for missing configuration files, and missing xml sections, thus, enabling the code to throw appropriate exceptions.
GetConfig(string)
Read a section of the config file, apply overrides and return the set of name/value pairs
Declaration
public static NameValueCollection GetConfig(string key)
Parameters
Type | Name | Description |
---|---|---|
string | key | Section path, such as "SuperOffice/Data/Explicit" |
Returns
Type | Description |
---|---|
NameValueCollection | Collection of name/value, including overrides |
Remarks
IMPORTANT:
Avoid reading directly from configurationfile like this;_values = (NameValueCollection)ConfigurationSettings.GetConfig("SuperOffice/Security/Sentry");
Instead use this;
_values = (NameValueCollection)ConfigFile.GetConfig("SuperOffice/Diagnostics");
This enables the code to check for missing configuration files, and missing xml sections, thus, enabling the code to throw appropriate exceptions.
HasOverride(string, string)
Check if the config value is overrided. This is needed in some cases where we don't want to override the overrides.
Declaration
public static bool HasOverride(string path, string keyName)
Parameters
Type | Name | Description |
---|---|---|
string | path | |
string | keyName |
Returns
Type | Description |
---|---|
bool | bool true if the config value is overrided |
Remarks
IMPORTANT:
Avoid reading directly from configurationfile like this;_values = (NameValueCollection)ConfigurationSettings.GetConfig("SuperOffice/Security/Sentry");
Instead use this;
_values = (NameValueCollection)ConfigFile.GetConfig("SuperOffice/Diagnostics");
This enables the code to check for missing configuration files, and missing xml sections, thus, enabling the code to throw appropriate exceptions.
RemoveAllOverrides()
Remove all overrides that have been set for config values. Remember that this is not retroactive for values that have already been read by business logic code.
Declaration
public static void RemoveAllOverrides()
Remarks
IMPORTANT:
Avoid reading directly from configurationfile like this;_values = (NameValueCollection)ConfigurationSettings.GetConfig("SuperOffice/Security/Sentry");
Instead use this;
_values = (NameValueCollection)ConfigFile.GetConfig("SuperOffice/Diagnostics");
This enables the code to check for missing configuration files, and missing xml sections, thus, enabling the code to throw appropriate exceptions.
RemoveOverride(string, string)
Remove one override. If not found, nothing happens
Declaration
public static void RemoveOverride(string path, string name)
Parameters
Type | Name | Description |
---|---|---|
string | path | |
string | name |
Remarks
IMPORTANT:
Avoid reading directly from configurationfile like this;_values = (NameValueCollection)ConfigurationSettings.GetConfig("SuperOffice/Security/Sentry");
Instead use this;
_values = (NameValueCollection)ConfigFile.GetConfig("SuperOffice/Diagnostics");
This enables the code to check for missing configuration files, and missing xml sections, thus, enabling the code to throw appropriate exceptions.
SetConfigFile(string)
Set the name of the .config file that NetServer is to use from now on. Previously read items will still be retained; new lookups will come from here.
Declaration
public static void SetConfigFile(string filePath)
Parameters
Type | Name | Description |
---|---|---|
string | filePath |
Remarks
This method should be used before proper NetServer startup/authentication. As with the AddOverride(string, string, string) method, it updates internal structures, but does not flush already-read configuration information (which of course influence things like assmelby loading etc; no way we could retroactively change those).
ToValueList(NameValueCollection)
Utility class used to access the SuperOffice entry in the Config file.
Declaration
public static List<string> ToValueList(this NameValueCollection col)
Parameters
Type | Name | Description |
---|---|---|
NameValueCollection | col |
Returns
Type | Description |
---|---|
List<string> |
Remarks
IMPORTANT:
Avoid reading directly from configurationfile like this;_values = (NameValueCollection)ConfigurationSettings.GetConfig("SuperOffice/Security/Sentry");
Instead use this;
_values = (NameValueCollection)ConfigFile.GetConfig("SuperOffice/Diagnostics");
This enables the code to check for missing configuration files, and missing xml sections, thus, enabling the code to throw appropriate exceptions.