-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebModule.cs
30 lines (25 loc) · 918 Bytes
/
WebModule.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
using Autofac;
using Microsoft.AspNetCore.Http;
using my_online_shop.Migrations.Data;
namespace my_online_shop
{
public class WebModule : Module
{
private string _connectionString;
private string _migrationAssemblyName;
public WebModule(string connectionString, string migrationAssemblyName)
{
_connectionString = connectionString;
_migrationAssemblyName = migrationAssemblyName;
}
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<PostgresDbContext>()
.WithParameter("connectionString", _connectionString)
.WithParameter("migrationAssemblyName", _migrationAssemblyName);
builder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>()
.InstancePerLifetimeScope();
base.Load(builder);
}
}
}