mutex
mutex

Reputation: 7728

SignalR and Autofac: Most up to date method of integrating

There is documentation for using Autofac with SignalR here:

https://code.google.com/p/autofac/wiki/SignalRIntegration

But this appears to be quite old. The 2.0 release of SignalR seems to have improved the story for DI. The following appears to be instructions for SignalR 2.0 DI:

http://www.asp.net/signalr/overview/signalr-20/extensibility/dependency-injection

Which is the preferred method and can anyone give some pointers on implementing the second approach with Autofac? Sorry I'm relatively new to both signalR and Autofac.

Upvotes: 0

Views: 605

Answers (1)

N. Taylor Mullen
N. Taylor Mullen

Reputation: 18301

Here's a nice way to use your own dependency resolver:

// This is all done in the initial startup
var myDependencyResolver = ....;

app.MapSignalR(new HubConfiguration
{
    Resolver = myDependencyResolver
});

// If you want to use GlobalHost you need to update its resolver.
GlobalHost.DependencyResolver = myDependencyResolver;

That's all you should need to do.

Hope this helps!

Upvotes: 1

Related Questions