Skip to content

Add SignalR Core integration package #27

@dotnetjunkie

Description

@dotnetjunkie

This package should do the following:

  • Implement a SimpleInjectorHubActivator<T> class
  • Add an extension method for registration of this class
  • Add an extension method that allows auto-registration of Hub classes, similar to the RegisterMvcControllers of the ASP.NET Core MVC integration package. i.e. it should register Hub classes based on the selected lifestyle (ILifestyleSelectionBehavior) and should suppress the disposable transient components warning in case the Hub implementation does not override Dispose(bool).

Especially this last point is the main reason why we need an integration package. Integrating SignalR without an integration package would have been trivial in case Hub would not have implemented IDisposable (and it shouln't have).

There are other complications, such as discussed here that should be taken into consideration, which are:

  • Hub classes do not always run in a web request (for instance with LongPolling), which means that they can be resolved without an active Simple Injector Scope.
  • This means SimpleInjectorHubActivator<T> must create a new Scope within its Create method, and dispose of the Scope in the Release method.
  • Although the creation of, and disposing of a scope, could be skipped in case an active scope (i.e. a web request scope) already exists, that could lead to complications, because the request might already have ended in some cases.
  • In case the absense of an active scope, the hub activator should be able to supply the Simple Injector ASP.NET Core integration with the active IServiceScope/IServiceProvider instance to prevent Simple Injector from creating a new IServiceScope internal, which would, again, lead to multiple instances of scoped registrations, but now for ASP.NET Core registered types. The hub should run in its own Simple Injector scope and MS.DI scope; reusing the same incoming MS.DI scope might have hard to predict side effects.

The following issues should be taken into consideration:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions