本文整理汇总了C#中Autofac.ContainerBuilder.RegisterLifetimeHubManager方法的典型用法代码示例。如果您正苦于以下问题:C# ContainerBuilder.RegisterLifetimeHubManager方法的具体用法?C# ContainerBuilder.RegisterLifetimeHubManager怎么用?C# ContainerBuilder.RegisterLifetimeHubManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Autofac.ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder.RegisterLifetimeHubManager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public void Register(ContainerBuilder builder)
{
builder.RegisterModule<NLogModule>();
builder.RegisterEventing();
builder.RegisterApiControllers(ThisAssembly);
builder.RegisterLifetimeHubManager();
builder.RegisterHubs(ThisAssembly);
builder.RegisterType<HomeControlServiceController>();
builder.RegisterType<ZWaveNotificationService>();
builder.RegisterAssemblyTypes(typeof(DependencyRegistrar).Assembly)
.Named<AbstractZWaveNotification>(t => t.Name);
builder.Register(ctx =>
{
HomeControlConfiguration hcCfg = null;
try
{
hcCfg = (HomeControlConfiguration)ConfigurationManager.GetSection("HomeControl");
}
catch (Exception ex)
{
LogManager.GetCurrentClassLogger().Fatal(ex);
}
return hcCfg ?? new HomeControlConfiguration();
}).As<HomeControlConfiguration>();
builder.Register(ctx => ctx.Resolve<HomeControlConfiguration>().ZWaveConfiguration);
builder.Register(ctx => ctx.Resolve<HomeControlConfiguration>().WebApi);
builder.RegisterType<OpenZWaveConfigurator>();
}
示例2: Bootstrap
public static void Bootstrap(Assembly entryAssembly)
{
var builder = new ContainerBuilder();
builder.RegisterControllers(entryAssembly);
builder.RegisterLifetimeHubManager();
builder.RegisterHubs(entryAssembly);
builder.RegisterAssemblyModules(typeof(DependencyInjectionConfiguration).Assembly);
builder.RegisterAssemblyModules(entryAssembly);
var container = builder.Build();
GlobalHost.DependencyResolver = new Autofac.Integration.SignalR.AutofacDependencyResolver(container);
DependencyResolver.SetResolver(new Autofac.Integration.Mvc.AutofacDependencyResolver(container));
}
示例3: BuildAndSetResolver
/// <summary>
/// 构建服务并设置SignalR平台的Resolver
/// </summary>
/// <param name="services">服务映射信息集合</param>
/// <param name="assemblies">要检索的程序集集合</param>
protected override IServiceProvider BuildAndSetResolver(IServiceCollection services, Assembly[] assemblies)
{
ContainerBuilder builder = new ContainerBuilder();
builder.RegisterHubs(assemblies).AsSelf().PropertiesAutowired();
builder.RegisterLifetimeHubManager();
builder.Populate(services);
IContainer container = builder.Build();
IDependencyResolver resolver = new AutofacDependencyResolver(container);
GlobalHost.DependencyResolver = resolver;
SignalRIocResolver.LifetimeResolveFunc = type =>
{
ILifetimeScope scope = CallContext.LogicalGetData(LifetimeHubManager.LifetimeScopeKey) as ILifetimeScope;
if (scope == null)
{
return null;
}
return scope.ResolveOptional(type);
};
return resolver.Resolve<IServiceProvider>();
}