/
MicroKernel.cs
78 lines (65 loc) · 2.58 KB
/
MicroKernel.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System.Configuration;
using System.Web.Mvc;
using System.Web.Security;
using Castle.Components.DictionaryAdapter;
using Castle.MicroKernel;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Castle.Windsor.Installer;
using SymbolSource.Gateway.Core;
using SymbolSource.Gateway.NuGet.Core;
using SymbolSource.Gateway.OpenWrap.Core;
using SymbolSource.Gateway.WinDbg.Core;
using SymbolSource.Processing.Basic;
namespace SymbolSource.Server.Basic
{
public class MicroKernel
{
public static IKernel Install()
{
var container = new WindsorContainer();
container.Install(new ProcessingBasicInstaller());
RegisterManagers(container);
container.Register(
AllTypes.FromAssembly(typeof(Gateway.NuGet.Core.AttributeRouting).Assembly)
.BasedOn<IController>()
.Configure(cr => cr.LifeStyle.Transient)
);
container.Register(
AllTypes.FromAssembly(typeof(Gateway.OpenWrap.Core.AttributeRouting).Assembly)
.BasedOn<IController>()
.Configure(cr => cr.LifeStyle.Transient)
);
container.Register(
AllTypes.FromAssembly(typeof(Gateway.WinDbg.Core.AttributeRouting).Assembly)
.BasedOn<IController>()
.Configure(cr => cr.LifeStyle.Transient)
);
ControllerBuilder.Current.SetControllerFactory(new MCControllerFactory(container.Kernel));
return container.Kernel;
}
private static void RegisterManagers(IWindsorContainer kernel)
{
kernel.Register(
Component.For<IGatewayBackendFactory<IWinDbgBackend>, IGatewayBackendFactory<IPackageBackend>>()
.ImplementedBy<BasicBackendFactory>()
);
kernel.Register(
Component.For<INuGetGatewayManager>()
.ImplementedBy<NuGetGatewayManager>()
);
kernel.Register(
Component.For<IOpenWrapGatewayManager>()
.ImplementedBy<OpenWrapGatewayManager>()
);
kernel.Register(
Component.For<IBasicBackendConfiguration>()
.ImplementedBy<BasicBackendConfiguration>()
);
kernel.Register(
Component.For<IGatewayConfigurationFactory>()
.ImplementedBy<AppSettingsConfigurationFactory>()
);
}
}
}