Implemented restorer, wired up for basic testing. Improved abstractions and fixed observer pattern issues
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
using MoonlightServers.Daemon.Helpers;
|
||||
using MoonlightServers.Daemon.Models.Cache;
|
||||
using MoonlightServers.Daemon.ServerSys.Abstractions;
|
||||
using MoonlightServers.Daemon.ServerSys.Implementations;
|
||||
|
||||
namespace MoonlightServers.Daemon.ServerSys;
|
||||
|
||||
@@ -16,24 +14,13 @@ public class ServerFactory
|
||||
|
||||
public Server CreateServer(ServerConfiguration configuration)
|
||||
{
|
||||
var serverMeta = new ServerMeta();
|
||||
serverMeta.Configuration = configuration;
|
||||
|
||||
// Build service collection
|
||||
serverMeta.ServiceCollection = new ServiceCollection();
|
||||
var scope = ServiceProvider.CreateAsyncScope();
|
||||
|
||||
// Configure service pipeline for the server components
|
||||
serverMeta.ServiceCollection.AddSingleton<IConsole, DockerConsole>();
|
||||
serverMeta.ServiceCollection.AddSingleton<IFileSystem, RawFileSystem>();
|
||||
var meta = scope.ServiceProvider.GetRequiredService<ServerContext>();
|
||||
|
||||
// TODO: Handle implementation configurations (e.g. virtual disk) here
|
||||
|
||||
// Combine both app service provider and our server instance specific one
|
||||
serverMeta.ServiceProvider = new CompositeServiceProvider([
|
||||
serverMeta.ServiceCollection.BuildServiceProvider(),
|
||||
ServiceProvider
|
||||
]);
|
||||
meta.Configuration = configuration;
|
||||
meta.ServiceScope = scope;
|
||||
|
||||
return serverMeta.ServiceProvider.GetRequiredService<Server>();
|
||||
return scope.ServiceProvider.GetRequiredService<Server>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user