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'm trying to create an Excel-like function syntax using nested static classes. I'm experiencing difficulties with some class names and nested classes. Below is the Fiddle code:
using System;using System.Collections.Generic;using System.Linq.Dynamic.Core;using System.Linq.Dynamic.Core.CustomTypeProviders;using System.Linq.Expressions;publicclassProgram{publicstaticvoidMain(){varconfig=new ParsingConfig
{CustomTypeProvider=new CustomTypeProvider(new[]{typeof(IST),typeof(IST.NOT)})};// Not working;varexpression="IS.NULL(null)";try{varresult= DynamicExpressionParser.ParseLambda(
config,false,new ParameterExpression[]{},typeof(bool),
expression
);
Console.WriteLine($"{expression} success");}catch(Exceptionex){
Console.WriteLine($"{expression} failed, because of {ex.GetType().FullName} with message {ex.Message}");}// Working;expression="IST.NULL(null)";try{varresult= DynamicExpressionParser.ParseLambda(
config,false,new ParameterExpression[]{},typeof(bool),
expression
);
Console.WriteLine($"{expression} success");}catch(Exceptionex){
Console.WriteLine($"{expression} failed, because of {ex.GetType().FullName} with message {ex.Message}");}// Not working;expression="IS.NOT.NULL(null)";try{varresult= DynamicExpressionParser.ParseLambda(
config,false,new ParameterExpression[]{},typeof(bool),
expression
);
Console.WriteLine($"{expression} success");}catch(Exceptionex){
Console.WriteLine($"{expression} failed, because of {ex.GetType().FullName} with message {ex.Message}");}// Not working;expression="IST.NOT.NULL(null)";try{varresult= DynamicExpressionParser.ParseLambda(
config,false,new ParameterExpression[]{},typeof(bool),
expression
);
Console.WriteLine($"{expression} success");}catch(Exceptionex){
Console.WriteLine($"{expression} failed, because of {ex.GetType().FullName} with message {ex.Message}");}}publicclassCustomTypeProvider:DefaultDynamicLinqCustomTypeProvider{privatereadonlyHashSet<Type>_types;publicCustomTypeProvider(Type[]types){_types=newHashSet<Type>(types);}publicoverrideHashSet<Type>GetCustomTypes(){return_types;}}publicstaticclassIS{publicstaticboolNULL(objectvalue)=>value==null;publicstaticclassNOT{publicstaticboolNULL(objectvalue)=>value!=null;}}publicstaticclassIST{publicstaticboolNULL(objectvalue)=>value==null;publicstaticclassNOT{publicstaticboolNULL(objectvalue)=>value!=null;}}}
2. Exception
Fiddle output:
IS.NULL(null) failed, because of System.Linq.Dynamic.Core.Exceptions.ParseException with message '(' expected
IST.NULL(null) success
IS.NOT.NULL(null) failed, because of System.Linq.Dynamic.Core.Exceptions.ParseException with message '(' expected
IST.NOT.NULL(null) failed, because of System.Linq.Dynamic.Core.Exceptions.ParseException with message Identifier expected
1. Description
I'm trying to create an Excel-like function syntax using nested static classes. I'm experiencing difficulties with some class names and nested classes. Below is the Fiddle code:
2. Exception
Fiddle output:
3. Fiddle
https://dotnetfiddle.net/nRMI2q
The text was updated successfully, but these errors were encountered: