public void HierarchicalResolutionWithOverride()
        {
            object test3        = _factory.GetObject("test3");
            object test         = _factory.GetObject("test");
            object testFactory1 = _factory.GetObject("testFactory1");

            IDictionary <string, object> objects = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(_factory, typeof(ITestObject), true, false);

            Assert.AreEqual(3, objects.Count);
            Assert.AreEqual(test3, objects["test3"]);
            Assert.AreEqual(test, objects["test"]);
            Assert.AreEqual(testFactory1, objects["testFactory1"]);
            objects = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(_factory, typeof(ITestObject), false, false);
            Assert.AreEqual(2, objects.Count);
            Assert.AreEqual(test, objects["test"]);
            Assert.AreEqual(testFactory1, objects["testFactory1"]);
            objects = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(_factory, typeof(ITestObject), false, true);
            Assert.AreEqual(2, objects.Count);
            Assert.AreEqual(test, objects["test"]);
            Assert.AreEqual(testFactory1, objects["testFactory1"]);
            objects = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(_factory, typeof(ITestObject), true, true);
            Assert.AreEqual(4, objects.Count);
            Assert.AreEqual(test3, objects["test3"]);
            Assert.AreEqual(test, objects["test"]);
            Assert.AreEqual(testFactory1, objects["testFactory1"]);
            Assert.IsTrue(objects["testFactory2"] is ITestObject);
            objects = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(_factory, typeof(DummyFactory), true, true);
            Assert.AreEqual(2, objects.Count);
            Assert.AreEqual(_factory.GetObject("&testFactory1"), objects["&testFactory1"]);
            Assert.AreEqual(_factory.GetObject("&testFactory2"), objects["&testFactory2"]);
            objects = ObjectFactoryUtils.ObjectsOfTypeIncludingAncestors(_factory, typeof(IFactoryObject), true, true);
            Assert.AreEqual(2, objects.Count);
            Assert.AreEqual(_factory.GetObject("&testFactory1"), objects["&testFactory1"]);
            Assert.AreEqual(_factory.GetObject("&testFactory2"), objects["&testFactory2"]);
        }
        /// <summary>
        /// Add the named advisor instance to the list of advisors.
        /// </summary>
        /// <param name="advisors">the advisor list</param>
        /// <param name="advisorName">the object name of the advisor to add</param>
        private void AddAdvisorCandidate(List <IAdvisor> advisors, string advisorName)
        {
            object advisorCandidate = _objectFactory.GetObject(advisorName);

            if (advisorCandidate is IAdvisor)
            {
                advisors.Add((IAdvisor)advisorCandidate);
            }
            else if (advisorCandidate is IAdvisors)
            {
                advisors.AddRange(((IAdvisors)advisorCandidate).Advisors);
            }
            else
            {
                throw new InvalidOperationException("expected type IAdvisor or IAdvisors but was " +
                                                    advisorCandidate.GetType().FullName);
            }
        }
 public void PostProcessObjectFactory(IConfigurableListableObjectFactory factory)
 {
     SPRNET1231FactoryObject testFactory = (SPRNET1231FactoryObject)factory.GetObject("testFactory");
     Assert.AreEqual(0, testFactory.count);
 }
示例#4
0
            public void PostProcessObjectFactory(IConfigurableListableObjectFactory factory)
            {
                SPRNET1231FactoryObject testFactory = (SPRNET1231FactoryObject)factory.GetObject("testFactory");

                Assert.AreEqual(0, testFactory.count);
            }