Framework Setup

This commit is contained in:
2020-04-19 21:56:56 -06:00
parent 3d4a0515e5
commit 1acf94c900
220 changed files with 809047 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
using System;
using DryIoc;
namespace BattleFieldSimulator
{
public class BootStrapper
{
private static readonly string NoBootstrapperMessage = $"Called {nameof(BootStrapper)} before it existed";
private static BootStrapper _bootStrapper;
private static IContainer _container;
public static BootStrapper Instance =>
_bootStrapper ?? throw new InvalidOperationException(NoBootstrapperMessage);
private BootStrapper(params IModule[] modules)
{
_container = new Container();
foreach (var module in modules)
{
module.Register(_container);
}
foreach (var module in modules)
{
module.Resolve(_container);
}
}
public static BootStrapper BootstrapSystem(params IModule[] modules) =>
_bootStrapper = new BootStrapper(modules);
public T Resolve<T>()
{
return _container.Resolve<T>();
}
}
}