Esempio n. 1
0
        static void Main(string[] args)
        {
            ConcretePrototype1 p1 = new ConcretePrototype1("I");
            ConcretePrototype1 c1 = (ConcretePrototype1)p1.Clone();

            Console.WriteLine("Cloned: {0}", c1.Id);

            ConcretePrototype2 p2 = new ConcretePrototype2("II");
            ConcretePrototype2 c2 = (ConcretePrototype2)p2.Clone();

            Console.WriteLine("Cloned: {0}", c2.Id);

            //Example
            ColorManager colormanager = new ColorManager();

            // Initialize with standard colors
            colormanager["red"]   = new Color(255, 0, 0);
            colormanager["green"] = new Color(0, 255, 0);
            colormanager["blue"]  = new Color(0, 0, 255);

            // User adds personalized colors
            colormanager["angry"] = new Color(255, 54, 0);
            colormanager["peace"] = new Color(128, 211, 128);
            colormanager["flame"] = new Color(211, 34, 20);

            // User clones selected colors
            Color color1 = colormanager["red"].Clone() as Color;
            Color color2 = colormanager["peace"].Clone() as Color;
            Color color3 = colormanager["flame"].Clone() as Color;

            Console.ReadKey();
        }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            var p1 = new ConcretePrototype1("I");
            var p2 = (ConcretePrototype1) p1.Clone();

            Console.WriteLine($"befor clone, Id={p1.Id}");
            Console.WriteLine($"after clone, Id={p2.Id}");

            Console.ReadKey();
        }
Esempio n. 3
0
        private static void Main(string[] args)
        {
            var p1 = new ConcretePrototype1("I");
            var p2 = (ConcretePrototype1)p1.Clone();

            Console.WriteLine($"befor clone, Id={p1.Id}");
            Console.WriteLine($"after clone, Id={p2.Id}");

            Console.ReadKey();
        }
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            // create a product using prototype 1
            Client    client     = new Client();
            Prototype prototype1 = new ConcretePrototype1();
            Prototype product1   = client.CreateProduct(prototype1);

            // create a product using prototype 2
            Prototype prototype2 = new ConcretePrototype2();
            Prototype product2   = client.CreateProduct(prototype2);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            // Create two instances and clone each
            ConcretePrototype1 p1 = new ConcretePrototype1("I");
            ConcretePrototype1 c1 = (ConcretePrototype1)p1.Clone();

            p1.Id = "T";
            Console.WriteLine("Cloned: {0}", c1.Id);

            ConcretePrototype2 p2 = new ConcretePrototype2("II");
            ConcretePrototype2 c2 = (ConcretePrototype2)p2.Clone();

            Console.WriteLine("Cloned: {0}", c2.Id);

            // Wait for user
            Console.Read();
        }