Example #1
0
        static void Main(string[] args)
        {
            ConcretePrototype p1 = new ConcretePrototype();
            Console.WriteLine("Instead of creating the object from scratch we take the prototype");
            ConcretePrototype c1 = (ConcretePrototype)p1.Create();

            // Wait for user
            Console.Read();
        }
Example #2
0
        static void Main(string[] args)
        {
            ConcretePrototype p1 = new ConcretePrototype();

            Console.WriteLine("Instead of creating the object from scratch we take the prototype");
            ConcretePrototype c1 = (ConcretePrototype)p1.Create();

            // Wait for user
            Console.Read();
        }
        static void Main(string[] args)
        {
            // 孙悟空 原型
            MonkeyKingPrototype prototypeMonkeyKing = new ConcretePrototype("MonkeyKing");

            // 变一个
            MonkeyKingPrototype cloneMonkeyKing = prototypeMonkeyKing.Clone() as ConcretePrototype;
            Console.WriteLine("Cloned1:\t" + cloneMonkeyKing.Id);

            // 变两个
            MonkeyKingPrototype cloneMonkeyKing2 = prototypeMonkeyKing.Clone() as ConcretePrototype;
            Console.WriteLine("Cloned2:\t" + cloneMonkeyKing2.Id);
            Console.ReadLine();
        }