本文整理匯總了C#中Spring.Objects.Factory.Support.DefaultListableObjectFactory.AutowireObjectProperties方法的典型用法代碼示例。如果您正苦於以下問題:C# DefaultListableObjectFactory.AutowireObjectProperties方法的具體用法?C# DefaultListableObjectFactory.AutowireObjectProperties怎麽用?C# DefaultListableObjectFactory.AutowireObjectProperties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Spring.Objects.Factory.Support.DefaultListableObjectFactory
的用法示例。
在下文中一共展示了DefaultListableObjectFactory.AutowireObjectProperties方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AutowireExistingObjectByTypeWithDependencyCheck
public void AutowireExistingObjectByTypeWithDependencyCheck()
{
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
DependenciesObject existingObj = new DependenciesObject();
lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByType, true);
}
示例2: AutowireExistingObjectByTypeWithNoDependencyCheck
public void AutowireExistingObjectByTypeWithNoDependencyCheck()
{
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
DependenciesObject existingObj = new DependenciesObject();
lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByType, false);
Assert.IsNull(existingObj.Spouse);
}
示例3: AutowireExistingObjectByType
public void AutowireExistingObjectByType()
{
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
lof.RegisterObjectDefinition("test", rod);
DependenciesObject existingObj = new DependenciesObject();
lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByType, true);
TestObject test = (TestObject)lof.GetObject("test");
Assert.AreEqual(existingObj.Spouse, test);
}
示例4: AutowireByTypeWithInvalidAutowireMode
public void AutowireByTypeWithInvalidAutowireMode()
{
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
DependenciesObject obj = new DependenciesObject();
lof.AutowireObjectProperties(obj, AutoWiringMode.Constructor, true);
}
示例5: AutowireExistingObjectByNameWithNoDependencyCheck
public void AutowireExistingObjectByNameWithNoDependencyCheck()
{
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
lof.RegisterObjectDefinition("Spous", rod);
DependenciesObject existingObj = new DependenciesObject();
lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByName, false);
Assert.IsNull(existingObj.Spouse);
}
示例6: AutowireExistingObjectByNameWithDependencyCheck
public void AutowireExistingObjectByNameWithDependencyCheck()
{
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
lof.RegisterObjectDefinition("Spous", rod);
DependenciesObject existingObj = new DependenciesObject();
lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByName, true);
Assert.Fail("Should have thrown UnsatisfiedDependencyException");
}
示例7: AutowireExistingObjectByName
public void AutowireExistingObjectByName()
{
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
lof.RegisterObjectDefinition("Spouse", rod);
DependenciesObject existingObj = new DependenciesObject();
lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByName, true);
TestObject spouse = (TestObject)lof.GetObject("Spouse");
Assert.AreEqual(existingObj.Spouse, spouse);
Assert.IsTrue(ObjectFactoryUtils.ObjectOfType(lof, typeof(TestObject)) == spouse);
}
示例8: AutowireExistingObjectByTypeWithDependencyCheck
public void AutowireExistingObjectByTypeWithDependencyCheck()
{
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
DependenciesObject existingObj = new DependenciesObject();
Assert.Throws<UnsatisfiedDependencyException>(() => lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByType, true));
}
示例9: AutowireByTypeWithInvalidAutowireMode
public void AutowireByTypeWithInvalidAutowireMode()
{
DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
DependenciesObject obj = new DependenciesObject();
Assert.Throws<ArgumentException>(() => lof.AutowireObjectProperties(obj, AutoWiringMode.Constructor, true));
}