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.
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 |
---|---|
Boolean | true if there was already an override for this path/name combination, false if not. The last call to AddOverride wins! |
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 |
---|---|
Boolean | True if there was already an override for one of the path/name combinations, false if not. |
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")) |
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 |
GetEffectiveConfig()
Declaration
public static string GetEffectiveConfig()
Returns
Type | Description |
---|---|
String |
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 |
---|---|
Boolean | bool true if the config value is overrided |
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()
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 |
SaveEffectiveConfig(String)
Construct the "effective" config, including overrides, and write it to the given file
Declaration
public static void SaveEffectiveConfig(string fullPath)
Parameters
Type | Name | Description |
---|---|---|
String | fullPath |
Remarks
No file is written if the file already exists and has the correct content. If the existing file does not exist or cannot be opened, then writing will be attempted. If writing fails, then the method will wait for one second and try again (in case of conflict with another process); after five attempts it gives up. No exceptions are thrown, regardless of outcome.
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)
Declaration
public static List<string> ToValueList(this NameValueCollection col)
Parameters
Type | Name | Description |
---|---|---|
NameValueCollection | col |
Returns
Type | Description |
---|---|
List<String> |