本文整理汇总了C#中SimpleInjector.Container.RegisterModules方法的典型用法代码示例。如果您正苦于以下问题:C# Container.RegisterModules方法的具体用法?C# Container.RegisterModules怎么用?C# Container.RegisterModules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleInjector.Container
的用法示例。
在下文中一共展示了Container.RegisterModules方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configuration
/// <summary>
/// Configure all the OWIN modules that participate in each request.
/// </summary>
/// <param name="app">The OWIN appBuilder</param>
/// <remarks>
/// The order of configuration is IMPORTANT - it sets the sequence of the request processing pipeline.
/// </remarks>
public void Configuration(IAppBuilder app)
{
#if DEBUG
// Debug builds get full call stack in error pages.
app.Properties["host.AppMode"] = "development";
#else
app.Properties["host.AppMode"] = "release";
#endif
// DependencyInjection config
var diContainer = new Container { Options = { AllowOverridingRegistrations = true } };
diContainer.RegisterModules(new ODataServiceModule(), new AppModule());
// Configure logging
ConfigureOwinLogging(app, diContainer);
// Web API config
var webApiConfig = new HttpConfiguration();
webApiConfig.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(diContainer);
// Map routes using class attributes
webApiConfig.MapHttpAttributeRoutes();
HttpServer webApiServer = new HttpServer(webApiConfig);
WebApiConfig.ConfigureODataService(webApiConfig, webApiServer);
app.UseWebApi(webApiServer);
}
示例2: CreateTestServer
/// <summary>
/// Returns a new <see cref="TestServer"/>, configured with WebApp.Web startup code.
/// Requests against the test server are processed directly in memory without going over the network.
/// </summary>
/// <param name="iocModule">Configures the odata model for the test in SimpleInjector</param>
/// <param name="odataConfigAction">Optional configuration for <see cref="ODataServerConfigurer"/>.</param>
/// <returns></returns>
/// <remarks>
/// Note that the returned <see cref="TestServer"/> should be disposed.
/// </para>
/// </remarks>
protected TestServer CreateTestServer(IModule iocModule, Action<ODataServerConfigurer> odataConfigAction = null)
{
// Setup the DI container
Container container = new Container { Options = { AllowOverridingRegistrations = true } };
container.RegisterModules(new ODataServiceModule(), iocModule);
var testServer = TestServer.Create(owinAppBuilder => ConfigureOwinPipeline(owinAppBuilder, container, odataConfigAction));
// Ensure logging setup is healthy
_tracerFactory.TracerFor(this).Info("Test OData server started...");
Assert.True(_logManager.IsHealthy);
return testServer;
}
示例3: Application_Start
protected void Application_Start()
{
// ASP.NET MVC setup
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
// DI config
var container = new Container { Options = { AllowOverridingRegistrations = true } };
container.RegisterModules(new ODataServiceModule(), new AppModule());
// Web API config
GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
GlobalConfiguration.Configure(WebApiConfig.Register);
//MvcRouteConfig.RegisterRoutes(RouteTable.Routes);
}