當前位置: 首頁>>代碼示例>>C#>>正文


C# DefaultListableObjectFactory.Dispose方法代碼示例

本文整理匯總了C#中Spring.Objects.Factory.Support.DefaultListableObjectFactory.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# DefaultListableObjectFactory.Dispose方法的具體用法?C# DefaultListableObjectFactory.Dispose怎麽用?C# DefaultListableObjectFactory.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Spring.Objects.Factory.Support.DefaultListableObjectFactory的用法示例。


在下文中一共展示了DefaultListableObjectFactory.Dispose方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: InnerObjectsInPrototype

        public void InnerObjectsInPrototype()
        {
            DefaultListableObjectFactory xof = new DefaultListableObjectFactory();
            XmlObjectDefinitionReader reader = new XmlObjectDefinitionReader(xof);
            reader.LoadObjectDefinitions(new ReadOnlyXmlTestResource("reftypes.xml", GetType()));
            TestObject hasInnerObjects = (TestObject) xof.GetObject("prototypeHasInnerObjects");
            Assert.AreEqual(5, hasInnerObjects.Age);

            Assert.IsNotNull(hasInnerObjects.Spouse);
            Assert.AreEqual("inner1", hasInnerObjects.Spouse.Name);
            Assert.AreEqual(6, hasInnerObjects.Spouse.Age);
            Assert.IsNotNull(hasInnerObjects.Friends);
            IList friends = (IList) hasInnerObjects.Friends;
            Assert.AreEqual(2, friends.Count);
            DerivedTestObject inner2 = (DerivedTestObject) friends[0];
            Assert.AreEqual("inner2", inner2.Name);
            Assert.AreEqual(7, inner2.Age);


            IList friendsOfInner = (IList) inner2.Friends;
            Assert.AreEqual(1, friendsOfInner.Count);
            DerivedTestObject innerFriendOfAFriend = (DerivedTestObject) friendsOfInner[0];
            Assert.AreEqual("innerFriendOfAFriend", innerFriendOfAFriend.Name);
            Assert.AreEqual(7, innerFriendOfAFriend.Age);
            TestObject innerFactory = (TestObject) friends[1];
            Assert.AreEqual(DummyFactory.SINGLETON_NAME, innerFactory.Name);
            Assert.IsNotNull(hasInnerObjects.SomeMap);
            Assert.IsFalse((hasInnerObjects.SomeMap.Count == 0));

            TestObject inner3 = (TestObject) hasInnerObjects.SomeMap["someKey"];
            Assert.AreEqual("inner3", inner3.Name);
            Assert.AreEqual(8, inner3.Age);
            xof.Dispose();
            
            Assert.IsFalse(inner2.WasDestroyed());
            Assert.IsFalse(innerFactory.Name == null);
            Assert.IsFalse(innerFriendOfAFriend.WasDestroyed());
            
        }
開發者ID:fgq841103,項目名稱:spring-net,代碼行數:39,代碼來源:XmlObjectFactoryTests.cs

示例2: InnerObjects

        public void InnerObjects()
        {
            DefaultListableObjectFactory xof = new DefaultListableObjectFactory();
            XmlObjectDefinitionReader reader = new XmlObjectDefinitionReader(xof);
            reader.LoadObjectDefinitions(new ReadOnlyXmlTestResource("reftypes.xml", GetType()));

            // Let's create the outer bean named "innerObject",
            // to check whether it doesn't create any conflicts
            // with the actual inner object named "innerObject".
            xof.GetObject("innerObject");

            TestObject hasInnerObjects = (TestObject) xof.GetObject("hasInnerObjects");
            Assert.AreEqual(5, hasInnerObjects.Age);           
            TestObject inner1 = (TestObject) hasInnerObjects.Spouse;
            Assert.IsNotNull(inner1);            
            Assert.AreEqual("Spring.Objects.TestObject#", inner1.ObjectName.Substring(0, inner1.ObjectName.IndexOf("#")+1));            
            Assert.AreEqual("inner1", inner1.Name);
            Assert.AreEqual(6, inner1.Age);
            
            
            Assert.IsNotNull(hasInnerObjects.Friends);
            IList friends = (IList) hasInnerObjects.Friends;
            Assert.AreEqual(2, friends.Count);
            DerivedTestObject inner2 = (DerivedTestObject) friends[0];
            Assert.AreEqual("inner2", inner2.Name);
            Assert.AreEqual(7, inner2.Age);
            Assert.AreEqual("Spring.Objects.DerivedTestObject#", inner2.ObjectName.Substring(0, inner2.ObjectName.IndexOf("#") + 1));      
            TestObject innerFactory = (TestObject) friends[1];
            Assert.AreEqual(DummyFactory.SINGLETON_NAME, innerFactory.Name);

            
            Assert.IsNotNull(hasInnerObjects.SomeMap);
            Assert.IsFalse((hasInnerObjects.SomeMap.Count == 0));
            TestObject inner3 = (TestObject) hasInnerObjects.SomeMap["someKey"];
            Assert.AreEqual("Jenny", inner3.Name);
            Assert.AreEqual(30, inner3.Age);
            xof.Dispose();
            Assert.IsTrue(inner2.WasDestroyed());
            Assert.IsTrue(innerFactory.Name == null);
        }
開發者ID:fgq841103,項目名稱:spring-net,代碼行數:40,代碼來源:XmlObjectFactoryTests.cs


注:本文中的Spring.Objects.Factory.Support.DefaultListableObjectFactory.Dispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。