title: Registering class types using DI Container
body: <p>I want to register some of classes which will be used by multiple different objects.
  It's hard to explain, but each of those registered classes have own "identifier" so I must registed it manually</p>
  
  <p>Here is registration part: (Startup.cs)</p>
  
  <pre><code>WebSocketHandler.AddHandler&lt;ChatHandler&gt;("/api/chat");
  </code></pre>
  
  <p>Registration method (manually created instances):</p>
  
  <pre><code>public static void AddHandler&lt;T&gt;(string path) where T: new()
  {
      var handler = new T() as IWebSocketHandler;
      handlers.Add(path, handler);
  }
  </code></pre>
  
  <p>But ChatHandler is used by another object, e.g ChatService</p>
  
  <pre><code>public ChatService(IChatHandler handler)
  {
      _handler = handler;
  }
  </code></pre>
  
  <p>The other problem is that the ChatHandler is descendent of WebSockethandler which requires WebSocketManager instance in constructor. </p>
  
  <p>How I can register objects like ChatHandler without manually crateing instances?</p>