Пример #1
0
        public static void Main_000(string[] args)
        {
            //Original copy of the ConcreteProtoType1
            ProtoType prototype = new ConcreteProtoType1 {
                Id = 10, Name = "Name of the ConcretePrototype1"
            };

            Display(prototype);

            //Cloned Copy of the ConcreteProtoType1 using Prototype
            var copy1 = (ConcreteProtoType1)prototype.Clone();

            Display(copy1);

            //Changed in the copy
            copy1.Id   = 90;
            copy1.Name = "Good name for concrete 1";
            Display(copy1);
            Display(prototype);

            Console.WriteLine();

            //Original copy of the ConcreteProtoType2
            prototype = new ConcreteProtoType2 {
                Id = 11, Name = "Name of the ConcretePrototype2"
            };
            Display(prototype);

            //Cloned Copy of the ConcreteProtoType2 using Prototype
            var copy2 = (ConcreteProtoType2)prototype.Clone();

            Display(copy2);

            //Changed copy
            copy2.Id   = 30;
            copy2.Name = "Good name for concrete 2";

            Display(copy2);
            Display(prototype);


            Console.ReadKey();
        }
Пример #2
0
        public static void Main_00(string[] args)
        {
            //Original copy of the ConcreteProtoType1
            ProtoType original = new ConcreteProtoType1 {
                Id = 10, Name = "Name of the ConcretePrototype1"
            };

            //Cloned Copy of the ConcreteProtoType1 using Prototype
            var prototype = original.Clone();

            //Original copy of the ConcreteProtoType2
            original = new ConcreteProtoType2 {
                Id = 11, Name = "Name of the ConcretePrototype2"
            };

            //Cloned Copy of the ConcreteProtoType2 using Prototype
            prototype = original.Clone();

            Console.ReadKey();
        }