josephnhtam / live-streaming-server-net

A .NET implementation of RTMP live streaming server, supporting HTTP-FLV, WebSocket-FLV, HLS, Kubernetes, cloud storage services integration and more.

Home Page:https://josephnhtam.github.io/live-streaming-server-net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Excessive use of IServiceProvider

f135ta opened this issue · comments

You have a very interesting approach to dependency injection, and coding in general.

The IServiceProvider has tripped me up several times when trying to work with the code. The nested dependencies make it difficult to understand which classes are actually used and where.

I'd suggest removing the IServiceProvider references and actually using the dependency injection built into Net Core properly. It will make the code easier to use, easier to test and easier to understand.

Microsoft recommendation for not using IServiceProvider

Hi @f135ta

Thank you for your suggestion.
I assume you are referring to the event dispatcher classes that use the observer or mediator pattern.
In my opinion, it is not uncommon to inject the IoC container, the IServiceProvider, to dynamically obtain references to the required handlers, especially for these patterns. Moreover, this approach helps avoid circular references by eliminating the need for direct dependencies.
However, any pull requests or discussions are very welcome.