Added maps
This commit is contained in:
@@ -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>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user