title: Getting resolved types inside a Ninject module
body: <p><strong>Problem</strong>: </p>
  
  <p>in my <em>domain layer assembly</em> I store two interfaces:</p>
  
  <pre><code>public interface IDomainEvent { }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public interface IHandle&lt;T&gt; where T: IDomainEvent, new()
  </code></pre>
  
  <p><code>EventDispatcher</code> class is defined there also:</p>
  
  <pre><code>public static class EventDispatcher {
      [ThreadStatic]
      private static List&lt;Delegate&gt; actions;
      [ThreadStatic]
      private static List&lt;Object&gt; handlers;
  
      public static List&lt;Object&gt; Handlers { 
          get { return handlers; } 
          set { handlers = value; } 
      }
  
      public static void Register&lt;T&gt;(Action&lt;T&gt; callback) where T : IDomainEvent, new() {
          if(null == actions) {
              actions = new List&lt;Delegate&gt;();
              actions.Add(callback);
          }
      }
  
      public static void ClearCallbacks() {
          actions = null;
      }
  
      public static void Raise&lt;T&gt;(T @event) where T : IDomainEvent, new() {
          if(null != Handlers) {
              foreach(var handler in Handlers.Where(h =&gt; h is IHandle&lt;T&gt;)) {
                  ((IHandle&lt;T&gt;)handler).Handle(@event);
              }
          }
  
          if(null != actions) {
              foreach(var action in actions) {
                  if(action is Action&lt;T&gt;) {
                      ((Action&lt;T&gt;)action)(@event);
                  }
              }
          } // if(null != actions) {
      }
  }
  </code></pre>
  
  <p>There's a module in presentation layer assembly:</p>
  
  <pre><code>public class EventDispatchingModule : NinjectModule {
  
      public override void Load() {
  
          // EventDispatcher.Handlers = this.Kernel.GetAll(IHandle&lt;T&gt;); Can't do that!
          // Bind&lt;IHandle&lt;CarHasBeenRegisteredEvent&gt;&gt;().To&lt;CarHasBeenRegisteredHandler();
      }
  }
  </code></pre>
  
  <p>So I can't call <code>Kernel.GetAll(IHandle&lt;T&gt;)</code> there because it can't resolve <code>T</code> parameter.</p>
  
  <p>Howcome I resolve this?</p>
  
  <p>Thanks!</p>