Создание и подключение контейнера
This commit is contained in:
parent
0f57d551c7
commit
99d1bee2ed
@ -8,4 +8,8 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,3 +1,7 @@
|
||||
using FuelAndLubricants.Repositories;
|
||||
using FuelAndLubricants.Repositories.Implementations;
|
||||
using Unity;
|
||||
|
||||
namespace FuelAndLubricants
|
||||
{
|
||||
internal static class Program
|
||||
@ -11,7 +15,21 @@ namespace FuelAndLubricants
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(CreateContainer().Resolve<Form1>());
|
||||
}
|
||||
|
||||
private static UnityContainer CreateContainer()
|
||||
{
|
||||
var container = new UnityContainer();
|
||||
|
||||
container.RegisterType<ICarRepository, CarRepository>();
|
||||
container.RegisterType<IDriverRepository, DriverRepository>();
|
||||
container.RegisterType<IFuelRepository, FuelRepository>();
|
||||
container.RegisterType<IRefillRepository, RefillRepository>();
|
||||
container.RegisterType<IRouteRepository, RouteRepository>();
|
||||
container.RegisterType<ITripRepository, TripRepository>();
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user