private static void CreationalPatterns() { #region Singleton Use.Applay(); /* * Computer comp = new Computer(); * comp.Launch("Windows 8.1"); * Console.WriteLine(comp.OS.Name); * * // у нас не получится изменить ОС, так как объект уже создан * comp.OS = OS.getInstance("Windows 10"); * Console.WriteLine(comp.OS.Name); */ Parallel.Invoke( () => S3_0(), () => S3_1() ); #endregion #region FactoryMethod DP.C.FactoryMethod.Use.Applay(); #endregion #region Prototype // Example 1 DP.C.Prototype.Use.Apply(); // Example 2 var prototype = new ConcretPrototype1 { Property1 = "A", Property2 = "B", PrototypeDetails = new PrototypeDetails { Details = "prototype Details" } }; var newObject = prototype.Clone() as ConcretPrototype1; newObject.PrototypeDetails.Details = "New details from newObject"; Console.WriteLine(prototype); Console.WriteLine(newObject); var prototype2 = new ConcretPrototype2 { OtherProperty = "Z", Property1 = "X", Property2 = "Y", PrototypeDetails = new PrototypeDetails { Details = "Prototype2 details" } }; // create new instance using prototype2 var newObject2 = prototype2.Clone() as ConcretPrototype2; newObject2.Property1 = "P01"; Console.WriteLine(prototype2); Console.WriteLine(newObject2); #endregion #region Builder Director director = new Director(); CarBuilder builder = new CarBuilder(); director.ConstructSportCar(builder); Car car = builder.GetResult(); CarManualBuilder carManualBuilder = new CarManualBuilder(); director.ConstructSportCar(carManualBuilder); Manual manual = carManualBuilder.GetResult(); #endregion //DP.B.Strategy.Real.Use.Applay(); //DP.B.Mediator.Real.Use.Apply(); //DP.S.Adapter.Real.Use.Applay(); Console.ReadLine(); }