Replace Constructor with FactoryMethod

Refactoring Steps:

  1. A constructor member is selected
  2. A new static 'Create' method is created with the same signature as the selected constructor.
  3. Code is inserted into the body of the new static method which creates and returns an instance of the parent type by calling the the selected constructor.
  4. The selected constructor's visibility is set to private.
  5. Each usage of the selected constructor in the solution is replaced with a call to the new static 'Create' method.

Replace constructor example:

   public class FactoryClass
   {
      public FactoryClass(int param1)
      {
         //
      }
   }
   public class ReferencingClass
   {
      public FactoryClass _factoryClass;
      public ReferencingClass(int param1)
      {
         _factoryClass = new FactoryClass(param1);
      }
   }
   // result below
   public class FactoryClass
   {
      private FactoryClass(int param1)
      {
         //
      }

      public static FactoryClass Create(int param1)
      {

         return new FactoryClass(param1);
      }

   }
   public class ReferencingClass
   {
      public FactoryClass _factoryClass;
      public ReferencingClass(int param1)
      {
         _factoryClass = FactoryClass.Create(param1);
      }
   }