Last active
December 25, 2015 22:19
-
-
Save isaacabraham/7048950 to your computer and use it in GitHub Desktop.
SignalR with IoC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Uses Unity to create Hubs - and ONLY Hubs. | |
/// </summary> | |
// Register with GlobalHost.DependencyResolver.Register(typeof(IHubActivator), () => unityHubActivator); | |
public class UnityHubActivator : IHubActivator | |
{ | |
private readonly IUnityContainer container; | |
public UnityHubActivator(IUnityContainer container) | |
{ | |
this.container = container; | |
} | |
public IHub Create(HubDescriptor descriptor) | |
{ | |
return (IHub)container.Resolve(descriptor.HubType); | |
} | |
} | |
public class ExampleHub : Hub | |
{ | |
private readonly IMyService myService; | |
private readonly ILogger logger; | |
public ExampleHub(IMyService myService, ILogger logger) | |
{ | |
this.myService = myService; | |
this.logger = logger; | |
} | |
// Blah blah.... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment