Is it possible to create a delegate dynamically like
arg => { return something; }
or arg => someting;
using the builtin DelegateFactoryObject and the Spring Expressions delivered with Spring.Net?
I want to create factories without coding. The abstract sample in the spring documentation requires an abstract factory and implements the factory method by config dynamically. I want to define a delegate and the result via Spring.Net.
I already use constructs like the following.
<object type="Spring.Objects.Factory.Config.DelegateFactoryObject">
<property name="DelegateType" value="System.Func<string,bool>" />
<property name="TargetObject" value="aString" />
<property name="MethodName" value="Equals" />
</object>
<object type="Spring.Objects.Factory.Config.DelegateFactoryObject">
<property name="DelegateType" value="System.Func<string,My.Interface>" />
<property name="TargetObject">
<object id="result" type="My.DelegateContainer<string,My.Interface>">
<constructor-arg name="objectToReturn" ref="theObjectToReturn" />
</object>
</property>
<property name="MethodName" value="Evaluate" />
</object>
(string is input and My.Interface implementing type is output, theObjectToReturn is passed through)
... but I am not able to find a solution how to use expressions to define a function that returns an object via xml-config. I want to replace the DelegateContainer in this example by a simple config-defined factory returning theObjectToReturn.
This question is related to this question: How to inject Predicate and Func in Spring.net and you can find more informations about the problem there.