本文整理汇总了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();
}
示例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();
}
示例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);
}
示例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>();
}
示例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;
}
示例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();
}
示例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());
}
示例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>();
}
示例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();
}
示例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();
}
示例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;
}
示例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)
});
}
示例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();
}
示例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();
}
示例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));
}