You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey.
I would like to have functionality to add extension methods to objects. So user could define spring (or .net) lambda function for specific type. For example:
varvars=newDictionary<string,object>{{"Foo",new Foo(){InternalValue=2}}};
Expressions.RegisterExtensionFunction<Foo>(vars,"SpelExtension","{|self, arg| $self.InternalValue + $arg}");
Expression.Parse("Foo.SpelExtension(1)").GetValue(null, vars);// result in Foo.InternalValue + 1 -> 3
Expressions.RegisterExtensionFunction<Foo,int>(vars,"CsExtension",(self,arg)=> sef.InternalValue +arg);
Expression.Parse("Foo.CsExtension(1)").GetValue(null, vars);// result in Foo.InternalValue + 1 -> 3
Expressions.RegisterExtensionProperty<Foo>(vars,"SpelProp","{|self| $self.InternalValue + 2}");
Expression.Parse("Foo.SpelProp").GetValue(null, vars);// result in Foo.InternalValue + 2 -> 4
Expressions.RegisterExtensionProperty<Foo>(vars,"CsProp",(self,arg)=> sef.InternalValue +2);
Expression.Parse("Foo.CsProp").GetValue(null, vars);// result in Foo.InternalValue + 2 -> 4
I have a quick and dirty POC that provides this functionality. I can clean it up and create PR. Are maintainers interested in this functionality?
The text was updated successfully, but these errors were encountered:
Hey.
I would like to have functionality to add extension methods to objects. So user could define spring (or .net) lambda function for specific type. For example:
I have a quick and dirty POC that provides this functionality. I can clean it up and create PR. Are maintainers interested in this functionality?
The text was updated successfully, but these errors were encountered: