I need to inject either through setter or constructor level a interface with spring .Net. I don't want to write spring.Net (use of ApplicationContext) code but accomplish it purely through XML. It seems like its not possible and my thinking is to use the static factory pattern. The problem comes when I create a instance of the object the property I set is null, so I'm not sure how to fire the injection without using the applicationContext methods.
My XML code.
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object id="foo" type="SpringIoC.Test.GlobalVariables, SpringIoC.Test">
<constructor-arg ref="anotherExampleObject"/>>
</object>
<object id="anotherExampleObject" type="SpringIoC.Implementor.HalloWorld, SpringIoC.Implementor"/>
</objects>
</spring>
My C# code:
public class GlobalVariables
{
public GlobalVariables(IHalloWorld hallo)
{
halloWorld = halloWorld;
}
private IHalloWorld halloWorld;
public IHalloWorld Hallo
{
set { halloWorld = value; }
}
public IHalloWorld getHallo
{
get { return halloWorld; }
}
}
The above XML are correct but how do i fire the injection without the use of applicationContext
?
How do I get my hands on a instance of GlobalVariables
without creating it through spring.Net.
The above is little confusing so please ask question if I'm not clear.