Skip to content

Instantly share code, notes, and snippets.

@thecopy
Last active December 19, 2015 04:48
Show Gist options
  • Save thecopy/5899197 to your computer and use it in GitHub Desktop.
Save thecopy/5899197 to your computer and use it in GitHub Desktop.
public static class MessageCenterOwinExtensions
{
public static IAppBuilder UseMessageCenter(this IAppBuilder app, TinyIoCDependencyResolver resolver)
{
var queueDocumentStore = new EmbeddableDocumentStore
{
RunInMemory = true
};
queueDocumentStore.Initialize();
resolver.BaseContainer.Register(typeof(IDocumentStore), (_,__) => queueDocumentStore);
resolver.BaseContainer.Register((c, __) => c.Resolve<IDocumentStore>().OpenSession());
resolver.BaseContainer.Register(GlobalHost.ConnectionManager).AsSingleton();
resolver.BaseContainer.Register<IMessageCenterService>((c, __) => new MessageCenterService(
c.Resolve<IDocumentSession>(),
c.Resolve<IConnectionManager>().GetHubContext<MessageCenterHub>()));
resolver.BaseContainer.Register<MessageCenterHub>();
app.MapHubs(new HubConfiguration
{
EnableCrossDomain = true,
EnableDetailedErrors = true,
Resolver = resolver
});
return app;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment