radu-matei / websocket-manager

Real-Time library for ASP .NET Core
https://radu-matei.com/blog/real-time-aspnet-core/
MIT License
452 stars 183 forks source link

Inject dependency rather than using new #69

Open radu-matei opened 6 years ago

radu-matei commented 6 years ago

https://github.com/radu-matei/websocket-manager/blob/master/samples/ChatApplication/ChatHandler.cs#L11

In one sample, a dependency needed for the handler is newed-up rather than injected using dependency injection. This should not be handled by the user of the library, but rather by the library itself:

        public ChatHandler(WebSocketConnectionManager webSocketConnectionManager) : base(webSocketConnectionManager, new ControllerMethodInvocationStrategy())
        {
            ((ControllerMethodInvocationStrategy)MethodInvocationStrategy).Controller = this;
        }

cc @Henry00IS