Is it possible to create a delegate dynamically, like
arg => { return something; } or arg => someting;
using the built-in DelegateFactoryObject file and Spring expressions supplied with Spring.Net?
I want to create factories without coding . An abstract sample in the Spring documentation requires an abstract factory and dynamically implements the factory method. I want to define the delegate and result through 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>
(a string is entered and the implementation type My.Interface is displayed, an ObjectToReturn object is passed)
... but I cannot 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 with a simple factory configuration that returns an ObjectToReturn object.
This question is related to this question: How to introduce Predicate and Func in Spring.net , and you can find additional information about the problem there.
source share