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


C# DefaultListableObjectFactory.GetObjectDefinition方法代碼示例

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


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

示例1: GetObjectDefinitionResolvesAliases

        public void GetObjectDefinitionResolvesAliases()
        {
            const string TheParentsAlias = "theParentsAlias";
            const int ExpectedAge = 31;
            const string ExpectedName = "Rick Evans";

            RootObjectDefinition parentDef = new RootObjectDefinition(typeof(TestObject));
            parentDef.IsAbstract = true;
            parentDef.PropertyValues.Add("name", ExpectedName);
            parentDef.PropertyValues.Add("age", ExpectedAge);

            ChildObjectDefinition childDef = new ChildObjectDefinition(TheParentsAlias);

            DefaultListableObjectFactory fac = new DefaultListableObjectFactory();

            fac.RegisterObjectDefinition("parent", parentDef);
            fac.RegisterAlias("parent", TheParentsAlias);

            IObjectDefinition od = fac.GetObjectDefinition(TheParentsAlias);
            Assert.IsNotNull(od);
        }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:21,代碼來源:DefaultListableObjectFactoryTests.cs

示例2: ParsesObjectAttributes

        public void ParsesObjectAttributes()
        {
            DefaultListableObjectFactory of = new DefaultListableObjectFactory();
            XmlObjectDefinitionReader reader = new XmlObjectDefinitionReader(of);
            reader.LoadObjectDefinitions(new StringResource(
@"<?xml version='1.0' encoding='UTF-8' ?>
<objects xmlns='http://www.springframework.net'>  
	<object id='test1' type='Spring.Objects.TestObject, Spring.Core.Tests' singleton='false' abstract='true' />
	<object id='test2' type='Spring.Objects.TestObject, Spring.Core.Tests' singleton='true' abstract='false' lazy-init='true' 
        autowire='no' dependency-check='simple'
        depends-on='test1' 
        init-method='init'
        destroy-method='destroy'
    />
</objects>
"));
            AbstractObjectDefinition od1 = (AbstractObjectDefinition)of.GetObjectDefinition("test1");
            Assert.IsFalse(od1.IsSingleton);
            Assert.IsTrue(od1.IsAbstract);
            Assert.IsFalse(od1.IsLazyInit);

            AbstractObjectDefinition od2 = (AbstractObjectDefinition)of.GetObjectDefinition("test2");
            Assert.IsTrue(od2.IsSingleton);
            Assert.IsFalse(od2.IsAbstract);
            Assert.IsTrue(od2.IsLazyInit);
            Assert.AreEqual(AutoWiringMode.No, od2.AutowireMode);
            Assert.AreEqual("init", od2.InitMethodName);
            Assert.AreEqual("destroy", od2.DestroyMethodName);
            Assert.AreEqual(1, od2.DependsOn.Length);
            Assert.AreEqual("test1", od2.DependsOn[0]);
            Assert.AreEqual(DependencyCheckingMode.Simple, od2.DependencyCheck);
        }
開發者ID:fuadm,項目名稱:spring-net,代碼行數:32,代碼來源:XmlObjectDefinitionReaderTests.cs

示例3: ChainedResolutionWithNullValues

        public void ChainedResolutionWithNullValues()
        {
            DefaultListableObjectFactory of = new DefaultListableObjectFactory();

            MutablePropertyValues pvs = new MutablePropertyValues();
            pvs.Add("NameProperty", "${name}");
            pvs.Add("NickNameProperty", "${nickname}");
            of.RegisterObjectDefinition("tb1", new RootObjectDefinition("typename", null, pvs));

            IList variableSources = new ArrayList();
            variableSources.Add(new DictionaryVariableSource(new string[] { "name", "name-value", "nickname", null }));
            variableSources.Add(new DictionaryVariableSource(new string[] { "nickname", "nickname-value" }));
            VariablePlaceholderConfigurer vphc = new VariablePlaceholderConfigurer(variableSources);

            vphc.PostProcessObjectFactory(of);
            RootObjectDefinition rod = (RootObjectDefinition)of.GetObjectDefinition("tb1");
            Assert.AreEqual("name-value", rod.PropertyValues.GetPropertyValue("NameProperty").Value);
            Assert.AreEqual(null, rod.PropertyValues.GetPropertyValue("NickNameProperty").Value);
        }
開發者ID:fgq841103,項目名稱:spring-net,代碼行數:19,代碼來源:VariablePlaceholderConfigurerTests.cs

示例4: ParsesAutowireCandidate

        public void ParsesAutowireCandidate()
        {
            DefaultListableObjectFactory of = new DefaultListableObjectFactory();
            XmlObjectDefinitionReader reader = new XmlObjectDefinitionReader(of);
            reader.LoadObjectDefinitions(new StringResource(
@"<?xml version='1.0' encoding='UTF-8' ?>
<objects xmlns='http://www.springframework.net' default-autowire-candidates='test1*,test4*'>  
	<object id='test1' type='Spring.Objects.TestObject, Spring.Core.Tests' />
	<object id='test2' type='Spring.Objects.TestObject, Spring.Core.Tests' autowire-candidate='false' />
	<object id='test3' type='Spring.Objects.TestObject, Spring.Core.Tests' autowire-candidate='true' />
	<object id='test4' type='Spring.Objects.TestObject, Spring.Core.Tests' autowire-candidate='default' />
	<object id='test5' type='Spring.Objects.TestObject, Spring.Core.Tests' autowire-candidate='default' />
</objects>
"));
            var od = (AbstractObjectDefinition)of.GetObjectDefinition("test1");
            Assert.That(od.IsAutowireCandidate, Is.True, "No attribute set should default to true");

            od = (AbstractObjectDefinition)of.GetObjectDefinition("test2");
            Assert.That(od.IsAutowireCandidate, Is.False, "Specifically attribute set to false should set to false");

            od = (AbstractObjectDefinition)of.GetObjectDefinition("test3");
            Assert.That(od.IsAutowireCandidate, Is.True, "Specifically attribute set to true should set to false");

            od = (AbstractObjectDefinition)of.GetObjectDefinition("test4");
            Assert.That(od.IsAutowireCandidate, Is.True, "Attribute set to default should check pattern and return true");

            od = (AbstractObjectDefinition)of.GetObjectDefinition("test5");
            Assert.That(od.IsAutowireCandidate, Is.False, "Attribute set to default should check pattern and return false");
        }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:29,代碼來源:XmlObjectDefinitionReaderTests.cs

示例5: MultiResolution

        public void MultiResolution()
        {
            DefaultListableObjectFactory of = new DefaultListableObjectFactory();
            MutablePropertyValues pvs = new MutablePropertyValues();
            pvs.Add("Greeting", "Hello ${firstname} ${lastname}!");
            of.RegisterObjectDefinition("tb1", new RootObjectDefinition("typename", null, pvs));

            IList variableSources = new ArrayList();
            variableSources.Add(new DictionaryVariableSource(new string[] { "firstname", "FirstName" }));
            variableSources.Add(new DictionaryVariableSource(new string[] { "lastname", "LastName" }));
            VariablePlaceholderConfigurer vphc = new VariablePlaceholderConfigurer(variableSources);
            vphc.PostProcessObjectFactory(of);

            RootObjectDefinition rod = (RootObjectDefinition)of.GetObjectDefinition("tb1");
            Assert.AreEqual("Hello FirstName LastName!", rod.PropertyValues.GetPropertyValue("Greeting").Value);
        }
開發者ID:fgq841103,項目名稱:spring-net,代碼行數:16,代碼來源:VariablePlaceholderConfigurerTests.cs


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