public void Factory4() { IComponentFactory2 factory = (IComponentFactory2)_container["compFactory2"]; Assert.IsNotNull(factory); IDummyComponent comp1 = (IDummyComponent)factory.Construct("comp1"); Assert.IsTrue(comp1 is Component1); Assert.IsNotNull(comp1); IDummyComponent comp2 = (IDummyComponent)factory.Construct("comp2"); Assert.IsTrue(comp2 is Component2); Assert.IsNotNull(comp2); }
public void Factory4() { _facility.AddTypedFactoryEntry( new FactoryEntry( "compFactory", typeof(IComponentFactory2), "Construct", "")); _container.AddComponent("comp1", typeof(IDummyComponent), typeof(Component1)); _container.AddComponent("comp2", typeof(IDummyComponent), typeof(Component2)); IComponentFactory2 factory = (IComponentFactory2)_container["compFactory"]; Assert.IsNotNull(factory); IDummyComponent comp1 = (IDummyComponent)factory.Construct("comp1"); Assert.IsTrue(comp1 is Component1); Assert.IsNotNull(comp1); IDummyComponent comp2 = (IDummyComponent)factory.Construct("comp2"); Assert.IsTrue(comp2 is Component2); Assert.IsNotNull(comp2); }