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


C# ContainerBuilder.RegisterLifetimeHubManager方法代码示例

本文整理汇总了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>();
        }
开发者ID:amyhickman,项目名称:HomeControl,代码行数:34,代码来源:DependencyRegistrar.cs

示例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));
        }
开发者ID:vgichar,项目名称:shah,代码行数:15,代码来源:DependencyInjectionConfiguration.cs

示例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>();
 }
开发者ID:liuxx001,项目名称:Bode,代码行数:25,代码来源:SignalRAutofacIocBuilder.cs


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