title: How do I instiate a class with it's dependencies using Ninject
body: <p>In my MVC application I have a concept of "scheduled job".</p>
  
  <p>A job inherits from an interface and is then (via reflection) automatically registered on application start.</p>
  
  <p>Now, in my application I am using Ninject for DI to help make my controllers more unit testable. I would love to use ninject for my Scheduled Jobs too but am currently using "poor man's DI" to instantiate my Job's with their dependencies.</p>
  
  <p>So, how exactly would I use Ninject instead of Poor Man's DI?</p>
  
  <p>Job Interface:</p>
  
  <pre><code>public interface IScheduledJob
  {
      /// &lt;summary&gt;
      /// Use Cron method to return frequency expression
      /// &lt;/summary&gt;
      string Frequency { get; }
  
      /// &lt;summary&gt;
      /// The entry point of the Job
      /// &lt;/summary&gt;
      void DoWork();
  }
  </code></pre>
  
  <p>Job Init Code:</p>
  
  <pre><code>private void ConfigureSchedules(IAppBuilder app)
      {
          // Get all types that implement the scheduler interface
          IEnumerable&lt;Type&gt; jobs = AppDomain.CurrentDomain.GetAssemblies()
              .SelectMany(s =&gt; s.GetTypes())
              .Where(p =&gt; typeof(IScheduledJob).IsAssignableFrom(p) &amp;&amp; !p.IsInterface);
          foreach (var jobType in jobs)
          {
              // Create instance of job
              IScheduledJob job = (IScheduledJob)Activator.CreateInstance(jobType);
              // Add to schedule
              RecurringJob.AddOrUpdate(() =&gt; job.DoWork(), job.Frequency);
          }
      }
  </code></pre>
  
  <p>Scheduled Job Ctors:</p>
  
  <pre><code>public class SynchronizerScheduledJob : IScheduledJob
  {
      #region Private Members
  
      private IMagentoSoapService _magentoSoapService;
      private IMagentoSoapCredentialProvider _credsProvider;
      private IUnitOfWork _unitOfWork;
      private IOrderHubService _orderHubService;
  
      #endregion
  
      #region Ctors
  
      public SynchronizerScheduledJob(
         IMagentoSoapService service,
         IMagentoSoapCredentialProvider credsProvider,
         IUnitOfWork unitOfWork,
         IOrderHubService orderHubService)
      {
          _magentoSoapService = service;
          _credsProvider = credsProvider;
          _unitOfWork = unitOfWork;
          _orderHubService = orderHubService;
      }
  
      /// &lt;summary&gt;
      /// Poor man's DI Ctor
      /// &lt;/summary&gt;
      public SynchronizerScheduledJob() : this(
              new MagentoSoapService(),
              new MagentoSoapCredentialProvider(),
              new UnitOfWork(AppDbContext.Create()),
              new OrderHubService())
      { }
  }
  </code></pre>