当前位置: 首页>>代码示例>>C#>>正文


C# ServiceContainer.EnablePerWebRequestScope方法代码示例

本文整理汇总了C#中ServiceContainer.EnablePerWebRequestScope方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceContainer.EnablePerWebRequestScope方法的具体用法?C# ServiceContainer.EnablePerWebRequestScope怎么用?C# ServiceContainer.EnablePerWebRequestScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServiceContainer的用法示例。


在下文中一共展示了ServiceContainer.EnablePerWebRequestScope方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Register

		public static void Register(ServiceContainer container, HttpConfiguration config)
		{
			container.RegisterControllers();
			container.RegisterApiControllers();

			#region Services
			container.Register<IPluralizeProxy, PluralizeProxy>();
			container.Register(factory => PluralizationService.CreateService(CultureInfo.GetCultureInfo("en")));
			container.Register<ISitemapGenerator, SitemapGenerator>();
			#endregion

			#region Tracing
			container.Register<IDiagnosticTrace, DiagnosticTrace>();
			#endregion

			#region Repositories
			container.Register<IDbContext, NhDbContext>();
			container.Register<IDataRepository<Repository>, DataRepository<Repository>>(new PerScopeLifetime());
			container.Register<IDataRepository<Session>, DataRepository<Session>>(new PerScopeLifetime());
			container.Register<IDataRepository<LogEntry>, DataRepository<LogEntry>>(new PerScopeLifetime());
			#endregion

			container.EnableMvc();
			container.EnablePerWebRequestScope();
			container.EnableWebApi(config);
		}
开发者ID:nHook,项目名称:nH.Web,代码行数:26,代码来源:DIConfig.cs

示例2: Application_Start

 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     var container = new ServiceContainer();
     container.RegisterApiControllers();
     container.Register<IDataStore, FakeDataStore>();
     container.EnablePerWebRequestScope();
     container.EnableWebApi(GlobalConfiguration.Configuration);
 }
开发者ID:chenzuo,项目名称:Restival,代码行数:9,代码来源:Global.asax.cs

示例3: Register

        /// <summary>
        /// Registers main components
        /// </summary>
        /// <param name="config">Http Configuration</param>
        public static void Register(HttpConfiguration config)
        {
            var container = new ServiceContainer();
            container.RegisterApiControllers();

            container.EnablePerWebRequestScope();
            container.EnableWebApi(GlobalConfiguration.Configuration);
            container.EnableMvc();

            // Register Services
            RegisterServices(container);
        }
开发者ID:ryanwoodcox,项目名称:HelloWorld,代码行数:16,代码来源:LightInjectConfig.cs

示例4: Register

		public static void Register(ServiceContainer container, HttpConfiguration config)
		{
			container.RegisterApiControllers();

			#region Tracing
			container.Register<IDiagnosticTrace, DiagnosticTrace>();
			container.Register<ITracer, NhTracer>();
			#endregion

			#region Loggers
			container.Register<ILogger, LoggerProxy>();
			container.Register<IConsole, ConsoleProxy>();
			#endregion

			#region Repositories
			container.Register<IDbContext, NhDbContext>(new PerContainerLifetime());
			container.Register<IDataRepository<Repository>, DataRepository<Repository>>(new PerScopeLifetime());
			container.Register<IDataRepository<Session>, DataRepository<Session>>(new PerScopeLifetime());
			container.Register<IDataRepository<LogEntry>, DataRepository<LogEntry>>(new PerScopeLifetime());
			#endregion

			#region Services
			container.Register<IActionContextService, ActionContextService>();
			container.Register<ISourceService, SourceService>();
			container.Register<IPathService, PathService>();
			container.Register<IPublishService, PublishService>();
			container.Register<IIOService, IOService>();
			container.Register<IPluralizeProxy, PluralizeProxy>();
			container.Register(factory => PluralizationService.CreateService(CultureInfo.GetCultureInfo("en")));
			#endregion

			#region Processors
			container.Register<INhContext, NhContext>(new PerScopeLifetime());
			container.Register<IProcessor<GitHubMessage>, GitHubProcessor>();
			container.Register<IProcessor<BitBucketMessage>, BitBucketProcessor>();
			#endregion

			#region Settings
			container.Register(factory => ConfigurationManager.AppSettings);
			#endregion

			container.EnablePerWebRequestScope();
			container.EnableWebApi(config);
		}
开发者ID:nHook,项目名称:nH.Api,代码行数:44,代码来源:DiConfig.cs

示例5: Application_Start

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var container = new ServiceContainer();
            container.RegisterApiControllers();

            container.Register<DbContext, TasksEntities>();
            container.Register<ITasksRepository, TasksRepository>(new PerScopeLifetime());
            container.Register<ITaskStatusesRepository, TaskStatusesRepository>(new PerScopeLifetime());
            container.Register<ITaskTypesRepository, TaskTypesRepository>(new PerScopeLifetime());

            container.EnablePerWebRequestScope();
            container.EnableWebApi(GlobalConfiguration.Configuration);
        }
开发者ID:snakeduse,项目名称:TestTasks,代码行数:19,代码来源:Global.asax.cs

示例6: WebTests

 static WebTests()
 {
     serviceContainer = new ServiceContainer();
     serviceContainer.Register<IFoo, Foo>(new PerScopeLifetime());
     serviceContainer.EnablePerWebRequestScope();
 }
开发者ID:dafanasiev,项目名称:LightInject,代码行数:6,代码来源:WebTests.cs


注:本文中的ServiceContainer.EnablePerWebRequestScope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。