-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDependencyResolver.cs
61 lines (45 loc) · 1.98 KB
/
DependencyResolver.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Autofac;
using AutoMapper;
using Science_News.Application.AutoMapper;
using Science_News.Application.Services.AppUserService;
using Science_News.Application.Services.AuthorService;
using Science_News.Application.Services.CategoryService;
using Science_News.Application.Services.PostService;
using Science_News.Domain.Repositories;
using Science_News.Infrastructure.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Science_News.Application.IoC
{
public class DependencyResolver : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<CategoryRepo>().As<ICategoryRepo>().InstancePerLifetimeScope();
builder.RegisterType<AuthorRepo>().As<IAuthorRepo>().InstancePerLifetimeScope();
builder.RegisterType<AppUserRepo>().As<IAppUserRepo>().InstancePerLifetimeScope();
builder.RegisterType<PostRepo>().As<IPostRepo>().InstancePerLifetimeScope();
builder.RegisterType<CategoryService>().As<ICategoryService>().InstancePerLifetimeScope();
builder.RegisterType<AuthorService>().As<IAuthorService>().InstancePerLifetimeScope();
builder.RegisterType<PostService>().As<IPostService>().InstancePerLifetimeScope();
builder.RegisterType<AppUserService>().As<IAppUserService>().InstancePerLifetimeScope();
builder.Register(context => new MapperConfiguration(cfg =>
{
cfg.AddProfile<Mapping>();
}
)).AsSelf().SingleInstance();
builder.Register(c =>
{
var context = c.Resolve<IComponentContext>();
var config = context.Resolve<MapperConfiguration>();
return config.CreateMapper(context.Resolve);
})
.As<IMapper>()
.InstancePerLifetimeScope();
base.Load(builder);
}
}
}