title: why I have to use IoC unity
body: <p>I create a class that applies to dependency inversion principle, and used the dependency injection pattern, as follows:</p>
  
  <pre><code>public interface ITypeOfPrinter
  {
      string Printing();
  }
  
  public class Print
  {  
      private readonly ITypeOfPrinter _typeOfPrinter;
  
      public Print(ITypeOfPrinter typeOfPrinter)
      {
          _typeOfPrinter = typeOfPrinter;
      }
  
      public string print()
      {
          return _typeOfPrinter.Printing();
      }
  }
  
  public class BlackAndWhitePrinter : ITypeOfPrinter
  {
      public string Printing()
      {
          NumberOfPrints++;
          return string.Format("it is Black and white printing {0}", NumberOfPrints);
      }
  
      public int NumberOfPrints { get; set; }
  
  }
  public class ColorfullPrinter : ITypeOfPrinter
  {
      public string Printing()
      {
          NumberOfPrints++;
          return string.Format("it is colorfull printing {0}", NumberOfPrints);
      }
      public int NumberOfPrints { get; set; }
  }
  </code></pre>
  
  <p>So if I want to use <code>BlackAndWhitePrinter</code>, I simply create an instance object and give it to my Print class with construction as follows:</p>
  
  <pre><code>ITypeOfPrinter typeofprinter = new BlackAndWhitePrinter();
  Print hp = new Print(typeofprinter);
  hp.print();
  </code></pre>
  
  <p>So Why I have to use Unity or another IoC framework here? I already did what I want as above:</p>
  
  <pre><code>var unityContainer = new UnityContainer();
  unityContainer.RegisterType&lt;ITypeOfPrinter, BlackAndWhitePrinter&gt;();
  var print = unityContainer.Resolve&lt;Print&gt;();
  string colorfullText = print.print();
  </code></pre>