forked from autofac/Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutofacModule.cs
More file actions
20 lines (19 loc) · 768 Bytes
/
Copy pathAutofacModule.cs
File metadata and controls
20 lines (19 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using Autofac;
using AspNetCoreExample.Services;
using Microsoft.Extensions.Logging;
namespace AspNetCoreExample
{
public class AutofacModule : Module
{
protected override void Load(ContainerBuilder builder)
{
// The generic ILogger<TCategoryName> service was added to the ServiceCollection by ASP.NET Core.
// It was then registered with Autofac using the Populate method. All of this starts
// with the services.AddAutofac() that happens in Program and registers Autofac
// as the service provider.
builder.Register(c => new ValuesService(c.Resolve<ILogger<ValuesService>>()))
.As<IValuesService>()
.InstancePerLifetimeScope();
}
}
}