public static void Main(string[] args) { var factoryClass = new FactoryClass <IDoWork>(); IDoWork newWork = factoryClass.Create("DoWorkType1"); Console.WriteLine(newWork.Process()); newWork = factoryClass.Create("DoWorkType2"); Console.WriteLine(newWork.Process()); Console.Read(); }
public static void Main(string[] args) { var newWork = FactoryClass.Create <IDoWork>("DoWorkType1"); Console.WriteLine(newWork.Process()); newWork = FactoryClass.Create <IDoWork>("DoWorkType2"); Console.WriteLine(newWork.Process()); // repeat with DoWorkType1 just to show it coming from dictionary newWork = FactoryClass.Create <IDoWork>("DoWorkType1"); Console.WriteLine(newWork.Process()); Console.Read(); }