Class ServerStorageService
- Namespace
- McServerLauncher.Services
- Assembly
- McServerLauncher.dll
Loads and saves the list of registered servers in %APPDATA%\McServerLauncher\servers.json.
public class ServerStorageService
- Inheritance
-
ServerStorageService
- Inherited Members
Constructors
ServerStorageService(string?)
Default constructor uses %APPDATA%; dataDir is for tests.
public ServerStorageService(string? dataDir = null)
Parameters
dataDirstring
Remarks
Same shape as AppSettingsService, and for the same reason: without it a test that goes anywhere near the server list reads and writes the real one on the machine running it. The two files live together, so whoever supplies a folder supplies it to both.
Properties
LastLoadOutcome
What happened with servers.json on the last Load(). Anything other than Ok should be surfaced to the user (the UI does it on startup) instead of silently showing an empty server list.
public AtomicJsonFile.LoadOutcome LastLoadOutcome { get; }
Property Value
QuarantinedFilePath
Where a corrupt servers.json is preserved (the ".bad" quarantine file).
public string QuarantinedFilePath { get; }
Property Value
Methods
Load()
Loads the list of servers. Returns an empty list if there is no file. If the file is corrupt, the last good ".bak" copy is restored when possible (see AtomicJsonFile); check LastLoadOutcome for what happened.
public List<ServerConfig> Load()
Returns
Save(IEnumerable<ServerConfig>)
Saves the list of servers (atomically; the previous version is kept as ".bak").
public void Save(IEnumerable<ServerConfig> servers)
Parameters
serversIEnumerable<ServerConfig>