public void Test() { //可以通过配置文件或者其他外部文件对客户程序进行注册,依赖注入 IAbstractFactoryWithTypeMapper factory = new ConcreteFactoryX(); AssemblerMechanism.Assembly(factory);//绑定TypeMapper IProductXB productXB = factory.Create <IProductXB>(); //******** }
public void Test1() { IAbstractFactoryWithTypeMapper factory = new ConcreteFactoryX(); AssemblyMechanism.Assembly(factory); IProductXB productXB = factory.Create <IProductXB>(); Assert.IsInstanceOf(typeof(ProductXB1), productXB); factory = new ConcreteFactoryY(); AssemblyMechanism.Assembly(factory); IProductYC productYC = factory.Create <IProductYC>(); Assert.IsInstanceOf(typeof(ProductYC1), productYC); }
public void Test1() { IAbstractFactoryWithTypeMapper factory = new ConcreteFactoryX(); AssemblyMechanism.Assembly(factory); IProductXB productXB = factory.Create <IProductXB>(); Assert.AreEqual(typeof(ProductXB1), productXB.GetType()); factory = new ConcreteFactoryY(); AssemblyMechanism.Assembly(factory); IProductYC productYC = factory.Create <IProductYC>(); Assert.AreEqual(typeof(ProductYC1), productYC.GetType()); }
public void Test() { IAbstarctFactoryWithTypeMapper factory = new ConcreteFactoryX(); AssemblyMechanism.Assembly(factory); // °ó¶¨TypeMapper IProductXB productXB = factory.Create <IProductXB>(); Assert.IsNotNull(productXB); Assert.AreEqual <Type>(typeof(ProductXB1), productXB.GetType()); // ²âÊÔÁíÒ»¸öAbstract Factory factory = new ConcreteFactoryY(); AssemblyMechanism.Assembly(factory); IProductYC productYC = factory.Create <IProductYC>(); Assert.IsNotNull(productYC); Assert.AreEqual <Type>(typeof(ProductYC1), productYC.GetType()); }