On the following page: http://www.asp.net/signalr/overview/signalr-20/extensibility/dependency-injection
Next to the bottom (just below the text "RegisterHubs.Start") is a snippet of Ninject code that I'm trying to reproduce using Autofac.
So far I have managed to give a headache, but not much more. I looked at the Autofac wiki files and web pages for some help. Although, I'm sure that I probably missed some tidbits of information.
Refresh . Here is the relevant Ninject code on the page.
public static class RegisterHubs { public static void Start() { var kernel = new StandardKernel(); var resolver = new NinjectSignalRDependencyResolver(kernel); kernel.Bind<IStockTicker>() .To<Microsoft.AspNet.SignalR.StockTicker.StockTicker>() .InSingletonScope(); kernel.Bind<IHubConnectionContext>().ToMethod(context => resolver.Resolve<IConnectionManager>(). GetHubContext<StockTickerHub>().Clients ).WhenInjectedInto<IStockTicker>(); var config = new HubConfiguration() { Resolver = resolver }; App.MapSignalR(config); } }
Update 2 . I think I will also add objects to be compiled.
public class StockTickerHub : Hub { private readonly IStockTicker _stockTicker; public StockTickerHub(IStockTicker stockTicker) { } } public class StockTicker { public StockTicker(IHubConnectionContext clients) { } }
c # ninject autofac signalr
Obscured
source share