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
I have written an implementation of IDynamicLinkCustomTypeProvider that load all my custom lynq functions:
When I use my DynamicLinqCustomTypeProvider I can use my Funcs.Left('asdfgh',3) fine as a expression, but unable to use Funcs.Left('asdfgh',3).Last()
Ie I am trying to make string extension methods that can be chained together. (Example below is just a simple one to show what I am trying to achieve) I have also noticed that GetExtensionMethods on DynamicLinqCustomTypeProvider is never called, but GetCustomTypes is called. Can you please help?
classDynamicLinqCustomTypeProvider:AbstractDynamicLinqCustomTypeProvider,IDynamicLinkCustomTypeProvider{publicvirtual HashSet GetCustomTypes(){...}publicDictionary<Type,List>GetExtensionMethods(){...}public Type ResolveType(stringtypeName){...}public Type ResolveTypeBySimpleName(stringsimpleTypeName){...}}namespaceExpressions{[DynamicLinqType]publicstaticclassFuncs{publicstaticstringLeft(objecttext,intnumChars){return Left(text asstring, numChars);}publicstaticstringLast(thisstringinput){return input.Substring(str.Length -1);}}}
To explain the requirement, we are trying to use the dynamic lynq in the following scenario.
Below is the way it work currently, but the bottom example is how I would like to use it. Hence I would like to make extension methods evaluate also. IE I have an custom method: Funcs.Split(...) that return a string[] and then a extension custom method that work in string[] and can join then ie Funcs.TextJoin(...)
In practice we will not Split and TextJoin like the unit test below, as the extension method we want to make is more complicated. The below was just to proof out one can make extension methods, that can be used in the dynamic lynq parser.
[Test]publicasync Task Expression_with_textleft_and_last(){dynamicrow=new ExpandoObject();
row.Address ="12 Church Street, Washington,United States";stringreturnValue= _expressionEvalutator.Evaluate<string>(row,"Funcs.TextJoin(\"|\", (Funcs.Split(\",\", Address)))");
Assert.AreEqual("12 Church Street| Washington|United States", returnValue);}[Test]publicasync Task Expression_with_textsplit_on_comma_and_join_by_pipe_ext(){dynamicrow=new ExpandoObject();
row.Address ="12 Church Street, Washington,United States";stringreturnValue= _expressionEvalutator.Evaluate<string>(row,"Funcs.Split(\",\", Address).TextJoin(\"|\")");
Assert.AreEqual("12 Church Street| Washington|United States", returnValue);}
The text was updated successfully, but these errors were encountered:
Hi,
I have written an implementation of IDynamicLinkCustomTypeProvider that load all my custom lynq functions:
When I use my DynamicLinqCustomTypeProvider I can use my
Funcs.Left('asdfgh',3)
fine as a expression, but unable to useFuncs.Left('asdfgh',3).Last()
Ie I am trying to make string extension methods that can be chained together. (Example below is just a simple one to show what I am trying to achieve) I have also noticed that GetExtensionMethods on DynamicLinqCustomTypeProvider is never called, but GetCustomTypes is called. Can you please help?
To explain the requirement, we are trying to use the dynamic lynq in the following scenario.
Below is the way it work currently, but the bottom example is how I would like to use it. Hence I would like to make extension methods evaluate also. IE I have an custom method: Funcs.Split(...) that return a string[] and then a extension custom method that work in string[] and can join then ie Funcs.TextJoin(...)
In practice we will not Split and TextJoin like the unit test below, as the extension method we want to make is more complicated. The below was just to proof out one can make extension methods, that can be used in the dynamic lynq parser.
The text was updated successfully, but these errors were encountered: