本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例6: WebTests
static WebTests()
{
serviceContainer = new ServiceContainer();
serviceContainer.Register<IFoo, Foo>(new PerScopeLifetime());
serviceContainer.EnablePerWebRequestScope();
}