Class FileServerConfiguration
Handles all logic related to loading, saving, and accessing the application's configuration settings from files.
public class FileServerConfiguration : IServerConfiguration
- Inheritance
-
FileServerConfiguration
- Implements
- Inherited Members
Constructors
FileServerConfiguration()
Initializes a new instance of the FileServerConfiguration class.
public FileServerConfiguration()
Methods
GetInt(string, int)
Retrieves an integer value from the configuration.
public int GetInt(string key, int defaultValue)
Parameters
keystringThe configuration key.
defaultValueintThe default value to return if the key is not found.
Returns
- int
The integer value associated with the key, or the default value if not found.
GetString(string, string)
Retrieves a string value from the configuration.
public string GetString(string key, string defaultValue)
Parameters
keystringThe configuration key.
defaultValuestringThe default value to return if the key is not found.
Returns
- string
The string value associated with the key, or the default value if not found.
GetUShort(string, ushort)
Retrieves an unsigned short value from the configuration.
public ushort GetUShort(string key, ushort defaultValue)
Parameters
keystringThe configuration key.
defaultValueushortThe default value to return if the key is not found.
Returns
- ushort
The ushort value associated with the key, or the default value if not found.
SaveDefaultsIfMissing(string, string, string)
Saves default configuration values if they are missing for the specified server type and working directory.
public void SaveDefaultsIfMissing(string serverTypeName, string serverType, string workingDirectory)
Parameters
serverTypeNamestringThe name of the server type.
serverTypestringThe type of the server.
workingDirectorystringThe working directory for the server.
TryGetInt(string, out int)
Attempts to retrieve an integer value from the configuration for the specified key.
public bool TryGetInt(string key, out int value)
Parameters
keystringThe configuration key to look up.
valueintWhen this method returns
true, contains the integer value associated withkey; otherwise0(or the default provided by the underlying implementation).
Returns
- bool
trueif the key exists and a value was retrieved; otherwisefalse.
TryGetString(string, out string)
Attempts to retrieve a string value from the configuration for the
specified key.
public bool TryGetString(string key, out string value)
Parameters
keystringThe configuration key to look up.
valuestringWhen this method returns
true, contains the string value associated withkey; otherwisenullor an empty string as provided by the underlying implementation.
Returns
- bool
trueif the key exists and a value was retrieved; otherwisefalse.
TryGetUShort(string, out ushort)
Attempts to retrieve an unsigned short value from the configuration for the specified key.
public bool TryGetUShort(string key, out ushort value)
Parameters
keystringThe configuration key to look up.
valueushortWhen this method returns
true, contains the ushort value associated withkey; otherwise0(or the default provided by the underlying implementation).
Returns
- bool
trueif the key exists and a value was retrieved; otherwisefalse.