예제 #1
0
        public static void TestCase1()
        {
            AbstractOrInterfaceOfPrototypeProduct prototypeProduct1 = new ConcretePrototypeProductA {
                ValueProperty1 = 1
            };
            AbstractOrInterfaceOfPrototypeProduct prototypeProduct2 = new ConcretePrototypeProductB {
                ValueProperty1 = 2
            };

            var manager = new ProductPrototypeManager();

            manager.Register("PrototypeProduct1", prototypeProduct1);
            manager.Register("PrototypeProduct2", prototypeProduct2);

            AbstractOrInterfaceOfPrototypeProduct clonedProduct1 = manager.Retrieve("PrototypeProduct1").Clone();

            Console.WriteLine(clonedProduct1.ValueProperty1);

            if (manager.IsRegisterd("PrototypeProduct2"))
            {
                AbstractOrInterfaceOfPrototypeProduct clonedProduct2 = manager.Retrieve("PrototypeProduct2").Clone();
                Console.WriteLine(clonedProduct2.ValueProperty1);
            }
        }
예제 #2
0
 public void Register(string name, AbstractOrInterfaceOfPrototypeProduct prototypeProduct)
 {
     _registry[name] = prototypeProduct;
 }