-
Notifications
You must be signed in to change notification settings - Fork 0
/
DependencyConfig.cs
40 lines (33 loc) · 1.2 KB
/
DependencyConfig.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
using System.Reflection;
using System.Web.Mvc;
using Aliencube.ReCaptcha.Wrapper.Interfaces;
using Autofac;
using Autofac.Integration.Mvc;
namespace Aliencube.ReCaptcha.Wrapper.WebApp
{
public static class DependencyConfig
{
public static void RegisterDependencies()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new AutofacWebTypesModule());
RegisterSettings(builder);
RegisterServices(builder);
RegisterControllers(builder);
var container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
}
private static void RegisterSettings(ContainerBuilder builder)
{
builder.Register(p => ReCaptchaV2Settings.CreateInstance()).As<IReCaptchaV2Settings>();
}
private static void RegisterServices(ContainerBuilder builder)
{
builder.RegisterType<ReCaptchaV2>().As<IReCaptchaV2>();
}
private static void RegisterControllers(ContainerBuilder builder)
{
builder.RegisterControllers(Assembly.GetExecutingAssembly()).PropertiesAutowired();
}
}
}