Interface IServerConfiguration
Interface for a service that manages server configuration. Provides methods to retrieve and save configuration values for different server types.
public interface IServerConfiguration
Methods
GetInt(string, int)
Retrieves an integer value from the configuration.
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.
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.
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.
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.
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.
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.
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.