On the following page: http://www.asp.net/signalr/overview/signalr-20/extensibility/dependency-injection
Near the bottom (just below the text "RegisterHubs.Start") there is a piece of Ninject code that I am trying to reproduce using Autofac.
So far I have succeeded in giving myself a headache, but not much else. I have scoured the Autofac wiki, and the web for some help. Though, I am sure I probably missed some tidbit of information.
Update: 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: Thought I would also add the objects trying to be composed.
public class StockTickerHub : Hub
{
private readonly IStockTicker _stockTicker;
public StockTickerHub(IStockTicker stockTicker) { }
}
public class StockTicker
{
public StockTicker(IHubConnectionContext clients) { }
}
RegisterHubs.Start
in the article. Where do you get stuck? Please post your code. – RepugnGlobalHost
in order to get the IConnectionManager? – Familist