Добавление IoC-контейнера
This commit is contained in:
parent
12c1611f71
commit
051acfeb0a
@ -1,6 +1,6 @@
|
|||||||
namespace ProjectConfectionaryFactory
|
namespace ProjectConfectionaryFactory
|
||||||
{
|
{
|
||||||
partial class Form1
|
partial class FormConfectionaryFactory
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
@ -1,8 +1,8 @@
|
|||||||
namespace ProjectConfectionaryFactory
|
namespace ProjectConfectionaryFactory
|
||||||
{
|
{
|
||||||
public partial class Form1 : Form
|
public partial class FormConfectionaryFactory : Form
|
||||||
{
|
{
|
||||||
public Form1()
|
public FormConfectionaryFactory()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
@ -1,3 +1,8 @@
|
|||||||
|
using Unity.Lifetime;
|
||||||
|
using Unity;
|
||||||
|
using ProjectConfectionaryFactory.Repositories;
|
||||||
|
using ProjectConfectionaryFactory.Repositories.Implementations;
|
||||||
|
|
||||||
namespace ProjectConfectionaryFactory
|
namespace ProjectConfectionaryFactory
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
@ -11,7 +16,19 @@ namespace ProjectConfectionaryFactory
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new Form1());
|
Application.Run(CreateContainer().Resolve<FormConfectionaryFactory>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IUnityContainer CreateContainer()
|
||||||
|
{
|
||||||
|
var container = new UnityContainer();
|
||||||
|
container.RegisterType<IClientRepository, ClientRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<IComponentRepository, ComponentRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<IOrderRepository, OrderRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<IProductRepository, ProductRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<ISupplierRepository, SupplierRepository>(new TransientLifetimeManager());
|
||||||
|
container.RegisterType<ISupplyRepository, SupplyRepository>(new TransientLifetimeManager());
|
||||||
|
return container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,4 +8,8 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Unity" Version="5.11.10" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
Loading…
x
Reference in New Issue
Block a user