Added maps

This commit is contained in:
Brady Bodily
2020-12-10 14:44:11 -07:00
parent 1cdf498800
commit 42dd13f7d6
16 changed files with 137 additions and 31 deletions

View File

@@ -1,7 +1,34 @@
using DryIoc;
using System;
namespace ConsoleApp
{
public class Bootstrapper
public class BootStrapper
{
p
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);
public 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>() => _container.Resolve<T>();
}
}