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


C# DefaultListableObjectFactory.Autowire方法代碼示例

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


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

示例1: AutowireWithUnsatisfiedConstructorDependency

 public void AutowireWithUnsatisfiedConstructorDependency()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     MutablePropertyValues pvs = new MutablePropertyValues();
     pvs.Add(new PropertyValue("name", "Rod"));
     RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject), pvs);
     lof.RegisterObjectDefinition("rod", rod);
     Assert.AreEqual(1, lof.ObjectDefinitionCount);
     lof.Autowire(typeof(UnsatisfiedConstructorDependency), AutoWiringMode.AutoDetect, true);
     Assert.Fail("Should have unsatisfied constructor dependency on SideEffectObject");
 }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:11,代碼來源:DefaultListableObjectFactoryTests.cs

示例2: AutowireWithNoDependencies

 public void AutowireWithNoDependencies()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
     lof.RegisterObjectDefinition("rod", rod);
     Assert.AreEqual(1, lof.ObjectDefinitionCount);
     object registered = lof.Autowire(typeof(NoDependencies), AutoWiringMode.AutoDetect, false);
     Assert.AreEqual(1, lof.ObjectDefinitionCount);
     Assert.IsTrue(registered is NoDependencies);
 }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:10,代碼來源:DefaultListableObjectFactoryTests.cs

示例3: AutowireWithSatisfiedConstructorDependency

 public void AutowireWithSatisfiedConstructorDependency()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     MutablePropertyValues pvs = new MutablePropertyValues();
     pvs.Add(new PropertyValue("name", "Rod"));
     RootObjectDefinition rood = new RootObjectDefinition(typeof(TestObject), pvs);
     lof.RegisterObjectDefinition("rod", rood);
     Assert.AreEqual(1, lof.ObjectDefinitionCount);
     object registered = lof.Autowire(typeof(ConstructorDependency), AutoWiringMode.AutoDetect, false);
     Assert.AreEqual(1, lof.ObjectDefinitionCount);
     ConstructorDependency kerry = (ConstructorDependency)registered;
     TestObject rod = (TestObject)lof.GetObject("rod");
     Assert.AreSame(rod, kerry._spouse);
 }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:14,代碼來源:DefaultListableObjectFactoryTests.cs

示例4: AutowireObjectByTypeWithDependencyCheck

 public void AutowireObjectByTypeWithDependencyCheck()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     lof.Autowire(typeof(DependenciesObject), AutoWiringMode.ByType, true);
     Assert.Fail("Should have thrown UnsatisfiedDependencyException");
 }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:6,代碼來源:DefaultListableObjectFactoryTests.cs

示例5: AutowireObjectByTypeWithNoDependencyCheck

 public void AutowireObjectByTypeWithNoDependencyCheck()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     DependenciesObject obj = (DependenciesObject)lof.Autowire(typeof(DependenciesObject), AutoWiringMode.ByType, false);
     Assert.IsNull(obj.Spouse);
 }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:6,代碼來源:DefaultListableObjectFactoryTests.cs

示例6: AutowireObjectByNameWithNoDependencyCheck

 public void AutowireObjectByNameWithNoDependencyCheck()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
     lof.RegisterObjectDefinition("Spous", rod);
     DependenciesObject obj = (DependenciesObject)lof.Autowire(typeof(DependenciesObject), AutoWiringMode.ByName, false);
     Assert.IsNull(obj.Spouse);
 }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:8,代碼來源:DefaultListableObjectFactoryTests.cs

示例7: AutowireObjectByType

 public void AutowireObjectByType()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
     lof.RegisterObjectDefinition("test", rod);
     DependenciesObject obj = (DependenciesObject)lof.Autowire(typeof(DependenciesObject), AutoWiringMode.ByType, true);
     TestObject test = (TestObject)lof.GetObject("test");
     Assert.AreEqual(obj.Spouse, test);
 }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:9,代碼來源:DefaultListableObjectFactoryTests.cs

示例8: AutowireObjectByNameWithDependencyCheck

 public void AutowireObjectByNameWithDependencyCheck()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
     lof.RegisterObjectDefinition("Spous", rod);
     lof.Autowire(typeof(DependenciesObject), AutoWiringMode.ByName, true);
 }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:7,代碼來源:DefaultListableObjectFactoryTests.cs

示例9: AutowireObjectByName

 public void AutowireObjectByName()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     RootObjectDefinition rodDefinition = new RootObjectDefinition(typeof(TestObject));
     rodDefinition.PropertyValues.Add("name", "Rod");
     rodDefinition.AutowireMode = AutoWiringMode.ByName;
     RootObjectDefinition kerryDefinition = new RootObjectDefinition(typeof(TestObject));
     kerryDefinition.PropertyValues.Add("name", "Kerry");
     lof.RegisterObjectDefinition("rod", rodDefinition);
     lof.RegisterObjectDefinition("Spouse", kerryDefinition);
     DependenciesObject obj = (DependenciesObject)lof.Autowire(typeof(DependenciesObject),
                                                                AutoWiringMode.ByName, true);
     TestObject objRod = (TestObject)lof.GetObject("rod");
     Assert.AreEqual(obj.Spouse, objRod.Spouse);
 }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:15,代碼來源:DefaultListableObjectFactoryTests.cs

示例10: AutowireConstructor

 public void AutowireConstructor()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
     lof.RegisterObjectDefinition("spouse", rod);
     ConstructorDependenciesObject cdo = (ConstructorDependenciesObject)lof.Autowire(typeof(ConstructorDependenciesObject),
                                                                                      AutoWiringMode.Constructor, true);
     object spouse = lof.GetObject("spouse");
     Assert.IsTrue(cdo.Spouse1 == spouse);
     Assert.IsTrue(ObjectFactoryUtils.ObjectOfType(lof, typeof(TestObject)) == spouse);
 }
開發者ID:ouyangyl,項目名稱:MySpringNet,代碼行數:11,代碼來源:DefaultListableObjectFactoryTests.cs

示例11: AutowireWithUnsatisfiedConstructorDependency

 public void AutowireWithUnsatisfiedConstructorDependency()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     MutablePropertyValues pvs = new MutablePropertyValues();
     pvs.Add(new PropertyValue("name", "Rod"));
     RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject), pvs);
     lof.RegisterObjectDefinition("rod", rod);
     Assert.AreEqual(1, lof.ObjectDefinitionCount);
     Assert.Throws<UnsatisfiedDependencyException>(() => lof.Autowire(typeof(UnsatisfiedConstructorDependency), AutoWiringMode.AutoDetect, true));
 }
開發者ID:spring-projects,項目名稱:spring-net,代碼行數:10,代碼來源:DefaultListableObjectFactoryTests.cs

示例12: AutowireObjectByTypeWithDependencyCheck

 public void AutowireObjectByTypeWithDependencyCheck()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     Assert.Throws<UnsatisfiedDependencyException>(() => lof.Autowire(typeof(DependenciesObject), AutoWiringMode.ByType, true));
 }
開發者ID:spring-projects,項目名稱:spring-net,代碼行數:5,代碼來源:DefaultListableObjectFactoryTests.cs


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