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


C# ContainerBuilder.RegisterHubs方法代码示例

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


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

示例1: Configuration

        public void Configuration(IAppBuilder app)
        {
            var builder = new ContainerBuilder();

            GlobalConfiguration.Configure(WebApiConfig.Register);

            var config = GlobalConfiguration.Configuration;
            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            builder.RegisterHubs(Assembly.GetExecutingAssembly());
            builder.RegisterWebApiFilterProvider(config);
            builder.RegisterHubs(Assembly.GetExecutingAssembly());
            builder.RegisterInstance(new GameService()).As<IGameService>().SingleInstance();
            var container = builder.Build();
            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
            GlobalHost.DependencyResolver = new AutofacDependencyResolver(container);

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var hubConfig = new HubConfiguration();
            hubConfig.Resolver = new AutofacDependencyResolver(container);

            app.UseAutofacMiddleware(container);
            app.MapSignalR();
        }
开发者ID:gobixm,项目名称:learn,代码行数:27,代码来源:OwinStartup.cs

示例2: Configure

        public static void Configure()
        {
            var builder = new ContainerBuilder();
            // Register MVC controllers and other stuffs
            builder.RegisterControllers(Assembly.GetExecutingAssembly());
            builder.RegisterHubs(Assembly.GetExecutingAssembly());

            // Register repositories
            builder.RegisterType<UserRepository>().As<IUserRepository>().InstancePerHttpRequest();
            builder.RegisterType<AttachmentRepository>().As<IAttachmentRepository>().InstancePerHttpRequest();
            builder.RegisterType<ActivityRepository>().As<IActivityRepository>().InstancePerHttpRequest();

            // Register other components
            builder.RegisterType<Configuration>().As<IConfiguration>();
            builder.RegisterType<FluentDbMigrator>().As<IDbMigrator>();

            #if DEBUG
            builder.RegisterType<AppDataAttachmentStorage>().As<IAttachmentStorage>();
            #else
            builder.RegisterType<AzureBlobAttachmentStorage>().As<IAttachmentStorage>();
            #endif

            var container = builder.Build();

            DependencyResolver.SetResolver(new Autofac.Integration.Mvc.AutofacDependencyResolver(container));
            GlobalHost.DependencyResolver = new Autofac.Integration.SignalR.AutofacDependencyResolver(container);

            // Run migrations
            var migrator = container.Resolve<IDbMigrator>();
            migrator.Run();
        }
开发者ID:vktr,项目名称:toughlings-web,代码行数:31,代码来源:ContainerConfig.cs

示例3: Configuration

        public void Configuration(IAppBuilder app)
        {
            ConfigureLogger();

            var builder = new ContainerBuilder();
            builder.RegisterLogger();
            builder.RegisterByAttributes(typeof (Startup).Assembly);
            builder.RegisterAssemblyModules(typeof (Startup).Assembly);
            builder.RegisterHubs(typeof (Startup).Assembly);
            var container = builder.Build();

            // config hubs
            var config = new HubConfiguration();
            config.Resolver = new AutofacDependencyResolver(container);

            app.UseJwtTokenAuthentication(container.Resolve<IssuerSetting>(),
                                          container.Resolve<AudienceSetting>(),
                                          container.Resolve<ClientSecretSetting>(),
                                          container.Resolve<ICurrentUserProvider>());

            app.MapSignalR(config);

            app.UseNancy(new NancyOptions
            {
                Bootstrapper = new NancyBootstrapper(container)
            });
            app.UseStageMarker(PipelineStage.MapHandler);
            app.UseCors(CorsOptions.AllowAll);

            JsonSettings.RetainCasing = false;

            SeedData(container);
        }
开发者ID:PatrickDinh,项目名称:Windtalker,代码行数:33,代码来源:Startup.cs

示例4: 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

示例5: RegisterAutoFac

 private void RegisterAutoFac()
 {
     var builder = new ContainerBuilder();
     builder.RegisterHubs(Assembly.GetExecutingAssembly());
     var container = builder.Build();
     var resolver = new AutofacDependencyResolver(container);
     GlobalHost.DependencyResolver = resolver;
 }
开发者ID:ahardin,项目名称:battleboats,代码行数:8,代码来源:Global.asax.cs

示例6: RegisterDependencies

 private static IContainer RegisterDependencies()
 {
     var builder = new ContainerBuilder();
     builder.RegisterHubs(Assembly.GetExecutingAssembly());
     builder.Register(c => new AccountNumberUserIdProvider()).AsImplementedInterfaces();
     builder.RegisterModule(new ServiceBusModule(Assembly.GetExecutingAssembly()));
     return builder.Build();
 }
开发者ID:amichel,项目名称:PaymentsGateway.MassTransit.Demo,代码行数:8,代码来源:IocConfig.cs

示例7: OnStart

        private static void OnStart()
        {
            var builder = new Autofac.ContainerBuilder();

            builder.RegisterHubs(System.Reflection.Assembly.GetAssembly(typeof(FNE.Eventing.EventBroker)));
            builder.RegisterType<NLogLoggingProvider>().AsImplementedInterfaces().InstancePerDependency();

            Microsoft.AspNet.SignalR.GlobalHost.DependencyResolver = new Autofac.Integration.SignalR.AutofacDependencyResolver(builder.Build());
        }
开发者ID:sellmeadog,项目名称:eventing,代码行数:9,代码来源:Program.cs

示例8: 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().AsSelf().PropertiesAutowired();
     builder.Populate(services);
     IContainer container = builder.Build();
     IDependencyResolver resolver = new AutofacDependencyResolver(container);
     GlobalHost.DependencyResolver = resolver;
     return resolver.Resolve<IServiceProvider>();
 }
开发者ID:donnieyoung,项目名称:osharp,代码行数:15,代码来源:SignalRAutofacIocBuilder.cs

示例9: RegisterServices

        private static IContainer RegisterServices(ContainerBuilder builder)
        {
            builder.RegisterHubs(Assembly.GetExecutingAssembly());

            builder.RegisterType<ChatEntitiesContext>().As<IEntitiesContext>();
            builder.RegisterGeneric(typeof(EntityRepository<>)).As(typeof(IEntityRepository<>));
            builder.RegisterType<MembershipService>().As<IMembershipService>();

            return builder.Build();
        }
开发者ID:FukKwang,项目名称:SignalRSamples,代码行数:10,代码来源:SignalRAutofac.cs

示例10: RegisterDependencies

        public static IContainer RegisterDependencies()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType<TestClass>();

            // Register your SignalR hubs.
            builder.RegisterHubs(Assembly.Load("SignalRChat.Web"));

            return builder.Build();
        }
开发者ID:maldworth,项目名称:SignalRChat-Autofac,代码行数:11,代码来源:IocConfig.cs

示例11: Register

        public static IContainer Register(IAppBuilder app, HttpConfiguration httpConfigurations)
        {
            var builder = new ContainerBuilder();
            var assembly = Assembly.GetExecutingAssembly();

            // web api controllers
            builder.RegisterApiControllers(assembly);

            // SignalR all hubs
            builder.RegisterHubs(assembly);

            // application related
            builder
                .RegisterType<TraceLogger>()
                .As<ILogger>()
                .SingleInstance();

            builder
                .RegisterType<InMemoryCounter>()
                .As<IDistributedCounter>()
                .SingleInstance();

            builder
                .RegisterType<AzureDocumentDb>()
                .As<IDocumentsService>()
                .SingleInstance()
                .WithParameters(new Parameter[] {
                    new PositionalParameter(0 , Environment.GetEnvironmentVariable("DOCUMENT_DB_ENDPOINT")),
                    new PositionalParameter(1, Environment.GetEnvironmentVariable("DOCUMENT_DB_ACCESS_KEY")),
                    new PositionalParameter(2, Environment.GetEnvironmentVariable("DOCUMENT_DB_NAME") ?? "development")});

            builder
                .RegisterType<AzureTableStorageService>()
                .As<ITableService>()
                .SingleInstance()
                .WithParameter("connectionString", Environment.GetEnvironmentVariable("STORAGE_CONNECTION_STRING") ?? "UseDevelopmentStorage=true");

            builder
                .RegisterType<AzureServiceBusSubscriptionService>()
                .As<ISubscriptionService>()
                .SingleInstance()
                .WithParameter("connectionString", Environment.GetEnvironmentVariable("SERVICEBUS_CONNECTION_STRING"));

            var container = builder.Build();

            // resolving in OWIN middleware
            app.UseAutofacMiddleware(container);

            // web api registration
            httpConfigurations.DependencyResolver = new AutofacWebApiDependencyResolver(container);

            return container;
        }
开发者ID:Enttoi,项目名称:enttoi-api,代码行数:53,代码来源:IocConfig.cs

示例12: Configuration

        public void Configuration(IAppBuilder application)
        {
            application.SetDefaultSignInAsAuthenticationType(DefaultAuthenticationTypes.ApplicationCookie);
            application.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                AuthenticationMode = AuthenticationMode.Active,
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/"),
            });

            var options = new GitHubAuthenticationOptions()
            {
                AuthenticationMode = AuthenticationMode.Active,
                AuthenticationType = "GitHub",
                SignInAsAuthenticationType = application.GetDefaultSignInAsAuthenticationType(),

                ClientId = ConfigurationManager.AppSettings["clientId"],
                ClientSecret = ConfigurationManager.AppSettings["clientSecret"],

                Provider = new GitHubAuthenticationProvider
                {
                    OnAuthenticated = context =>
                    {
                        context.Identity.AddClaim(new Claim("urn:github:avatar_url", context.User["avatar_url"].ToString()));
                        context.Identity.AddClaim(new Claim("urn:github:acess_token", context.AccessToken));

                        return Task.FromResult(0);
                    }
                }
            };

            options.Scope.Clear();

            application.UseGitHubAuthentication(options);

            var builder = new ContainerBuilder();
            builder.RegisterHubs(Assembly.GetExecutingAssembly());
            var container = builder.Build();

            application.Map("/signalr", map =>
             {
                 map.UseCors(CorsOptions.AllowAll);
                 var hubConfiguration = new HubConfiguration()
                 {
                     Resolver = new AutofacDependencyResolver(container)
                 };
                 map.RunSignalR(hubConfiguration);
             }).UseNancy(new NancyOptions()
             {
                 Bootstrapper = new Bootstrapper(container)
             });
        }
开发者ID:retran,项目名称:hackathon-async-chat,代码行数:52,代码来源:Startup.cs

示例13: Create

        public static IContainer Create()
        {
            var builder = new ContainerBuilder();

            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            builder.RegisterHubs(Assembly.GetExecutingAssembly());

            builder.RegisterType<UserInMemoryRepository>().As<IUserRepository>().SingleInstance();
            builder.RegisterType<AzureTableStorageMessageRepository>().As<IMessageRepository>().InstancePerLifetimeScope();
            builder.RegisterType<CloudTableFactory>().As<ICloudTableFactory>().SingleInstance();

            return builder.Build();
        }
开发者ID:sachevl,项目名称:Chat,代码行数:13,代码来源:AutofacContainerFactory.cs

示例14: Load

        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterHubs(Assembly.GetExecutingAssembly());
            builder.RegisterType<ImageCache>().SingleInstance();

            //var messageBus = new MessageBus();
            //builder
            //    .RegisterInstance(messageBus)
            //    .AsSelf();

            //builder
            //    .RegisterType(typeof(TestService))
            //    .AsSelf();
        }
开发者ID:neutmute,项目名称:PiCamCV,代码行数:14,代码来源:PiCamWebModule.cs

示例15: 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


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