tgstation-server  4.4.0
The /tg/station 13 server suite
DmbProvider.cs
Go to the documentation of this file.
1 using System;
2 using Tgstation.Server.Host.IO;
4 
5 namespace Tgstation.Server.Host.Components.Deployment
6 {
8  sealed class DmbProvider : IDmbProvider
9  {
11  public string DmbName => String.Concat(CompileJob.DmeName, DreamMaker.DmbExtension);
12 
14  public string Directory => ioManager.ResolvePath(CompileJob.DirectoryName.ToString() + directoryAppend);
15 
19  public CompileJob CompileJob { get; }
20 
25 
29  readonly string directoryAppend;
30 
34  Action onDispose;
35 
43  public DmbProvider(CompileJob compileJob, IIOManager ioManager, Action onDispose, string directoryAppend = null)
44  {
45  CompileJob = compileJob ?? throw new ArgumentNullException(nameof(compileJob));
46  this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
47  this.onDispose = onDispose ?? throw new ArgumentNullException(nameof(onDispose));
48  this.directoryAppend = directoryAppend ?? String.Empty;
49  }
50 
52  public void Dispose() => onDispose?.Invoke();
53 
55  public void KeepAlive() => onDispose = null;
56  }
57 }
readonly string directoryAppend
Extra path to add to the end of Api.Models.Internal.CompileJob.DirectoryName
Definition: DmbProvider.cs:29
string DmeName
The .dme file used for compilation
Definition: CompileJob.cs:16
readonly IIOManager ioManager
The IIOManager for the DmbProvider
Definition: DmbProvider.cs:24
const string DmbExtension
Extension for .dmbs
Definition: DreamMaker.cs:34
DmbProvider(CompileJob compileJob, IIOManager ioManager, Action onDispose, string directoryAppend=null)
Construct a DmbProvider
Definition: DmbProvider.cs:43
Guid DirectoryName
The Game folder the results were compiled into
Definition: CompileJob.cs:28
Action onDispose
The Action to run when Dispose is called
Definition: DmbProvider.cs:34
Provides absolute paths to the latest compiled .dmbs
Definition: IDmbProvider.cs:9
Interface for using filesystems
Definition: IIOManager.cs:11