tgstation-server 6.8.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
DelegatingEngineInstaller.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Frozen;
3using System.Linq;
4using System.Threading;
5using System.Threading.Tasks;
6
9
11{
16 {
20 readonly FrozenDictionary<EngineType, IEngineInstaller> delegatedInstallers;
21
26 public DelegatingEngineInstaller(FrozenDictionary<EngineType, IEngineInstaller> delegatedInstallers)
27 {
28 this.delegatedInstallers = delegatedInstallers ?? throw new ArgumentNullException(nameof(delegatedInstallers));
29 }
30
32 public Task CleanCache(CancellationToken cancellationToken)
33 => Task.WhenAll(delegatedInstallers.Values.Select(installer => installer.CleanCache(cancellationToken)));
34
36 public IEngineInstallation CreateInstallation(EngineVersion version, string path, Task installationTask)
37 => DelegateCall(version, installer => installer.CreateInstallation(version, path, installationTask));
38
40 public ValueTask<IEngineInstallationData> DownloadVersion(EngineVersion version, JobProgressReporter? jobProgressReporter, CancellationToken cancellationToken)
41 => DelegateCall(version, installer => installer.DownloadVersion(version, jobProgressReporter, cancellationToken));
42
44 public ValueTask Install(EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
45 => DelegateCall(version, installer => installer.Install(version, path, deploymentPipelineProcesses, cancellationToken));
46
48 public ValueTask TrustDmbPath(EngineVersion version, string fullDmbPath, CancellationToken cancellationToken)
49 => DelegateCall(version, installer => installer.TrustDmbPath(version, fullDmbPath, cancellationToken));
50
52 public ValueTask UpgradeInstallation(EngineVersion version, string path, CancellationToken cancellationToken)
53 => DelegateCall(version, installer => installer.UpgradeInstallation(version, path, cancellationToken));
54
62 TReturn DelegateCall<TReturn>(EngineVersion version, Func<IEngineInstaller, TReturn> call)
63 {
64 ArgumentNullException.ThrowIfNull(version);
65 return call(delegatedInstallers[version.Engine!.Value]);
66 }
67 }
68}
Information about an engine installation.
EngineType? Engine
The EngineType.
Implementation of IEngineInstaller that forwards calls to different IEngineInstaller based on their a...
IEngineInstallation CreateInstallation(EngineVersion version, string path, Task installationTask)
Creates an IEngineInstallation for a given version . The IEngineInstallation.
DelegatingEngineInstaller(FrozenDictionary< EngineType, IEngineInstaller > delegatedInstallers)
Initializes a new instance of the DelegatingEngineInstaller class.
ValueTask< IEngineInstallationData > DownloadVersion(EngineVersion version, JobProgressReporter? jobProgressReporter, CancellationToken cancellationToken)
Download a given engine version . A ValueTask<TResult> resulting in the IEngineInstallationData for t...
TReturn DelegateCall< TReturn >(EngineVersion version, Func< IEngineInstaller, TReturn > call)
Delegate a given call to its appropriate IEngineInstaller.
ValueTask Install(EngineVersion version, string path, bool deploymentPipelineProcesses, CancellationToken cancellationToken)
Does actions necessary to get an extracted installation working. A ValueTask representing the running...
ValueTask UpgradeInstallation(EngineVersion version, string path, CancellationToken cancellationToken)
Does actions necessary to get upgrade a version installed by a previous version of TGS....
Task CleanCache(CancellationToken cancellationToken)
Attempts to cleans the engine's cache folder for the system. A Task representing the running operatio...
readonly FrozenDictionary< EngineType, IEngineInstaller > delegatedInstallers
The FrozenDictionary<TKey, TValue> mapping EngineTypes to their appropriate IEngineInstaller.
ValueTask TrustDmbPath(EngineVersion version, string fullDmbPath, CancellationToken cancellationToken)
Add a given fullDmbPath to the trusted DMBs list in BYOND's config. A ValueTask representing the run...
For downloading and installing game engines for a given system.