O'Reilly logo

SignalR Real-time Application Cookbook by Roberto Vespa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introducing dependency injection (simple approach)

Let's now enter a different territory, where we'll learn how to fully integrate our code with the internal behaviors of SignalR. SignalR offers a powerful way to extend its functionalities through a dependency injection API and strategy. Thanks to that, we can easily hook into the Hub creation process, and consequently we have a way to inject other objects into it and make them available to its methods.

In this recipe, we'll illustrate how we can transparently inject a specific reusable logic inside a Hub when it's created. The Hub will expose a simple method receiving a string and returning a corresponding translation obtained from a translator service injected at its creation.

Getting ready

For ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required