protected ComputedExpression InterpretInternal( string expression, CancellationToken cancellationToken = default) { _ = Requires.NotNullOrWhiteSpace( expression, nameof(expression)); ThrowIfCurrentObjectDisposed(); using SynchronizationLocker innerLock = EnsureInitialization(); // Check expression through pass-through extractors if (constantPassThroughExtractors.KeysByLevel.SelectMany(p => p.Value) .Any( ConstantPassThroughExtractorPredicate, expression, this)) { return(new ComputedExpression( expression, new StringNode(expression), true, new StandardParameterRegistry(stringFormatters), stringFormatters, null)); }
/// <summary> /// Returns the prototypes of all registered functions. /// </summary> /// <returns>All function names, with all possible combinations of input and output data.</returns> public string[] GetRegisteredFunctions() { ThrowIfCurrentObjectDisposed(); using SynchronizationLocker innerLock = EnsureInitialization(); // Capacity is sum of all, times 3; the "3" number was chosen as a good-enough average of how many overloads are defined, on average var bldr = new List <string>( (nonaryFunctions.Count + unaryFunctions.Count + binaryFunctions.Count + ternaryFunctions.Count) * 3); bldr.AddRange(nonaryFunctions.Select(function => $"{function.Key}()")); ( from KeyValuePair <string, Type> function in unaryFunctions from ConstructorInfo constructor in function.Value.GetTypeInfo() .DeclaredConstructors let parameters = constructor.GetParameters() where parameters.Length == 1 let parameterName = parameters[0] .Name where parameterName != null let functionName = function.Key select(FunctionName: functionName, ParameterName: parameterName)).ForEach( ( parameter, bldrL1) => bldrL1.Add($"{parameter.FunctionName}({parameter.ParameterName})"), bldr); ( from KeyValuePair <string, Type> function in binaryFunctions from ConstructorInfo constructor in function.Value.GetTypeInfo() .DeclaredConstructors let parameters = constructor.GetParameters() where parameters.Length == 2 let parameterNameLeft = parameters[0] .Name let parameterNameRight = parameters[1] .Name where parameterNameLeft != null && parameterNameRight != null let functionName = function.Key select(FunctionName: functionName, ParameterNameLeft: parameterNameLeft, ParameterNameRight: parameterNameRight)).ForEach( ( parameter, bldrL1) => bldrL1.Add( $"{parameter.FunctionName}({parameter.ParameterNameLeft}, {parameter.ParameterNameRight})"), bldr); ( from KeyValuePair <string, Type> function in ternaryFunctions from ConstructorInfo constructor in function.Value.GetTypeInfo() .DeclaredConstructors let parameters = constructor.GetParameters() where parameters.Length == 3 let parameterNameLeft = parameters[0] .Name let parameterNameMiddle = parameters[1] .Name let parameterNameRight = parameters[2] .Name where parameterNameLeft != null && parameterNameMiddle != null && parameterNameRight != null let functionName = function.Key select(FunctionName: functionName, ParameterNameLeft: parameterNameLeft, ParameterNameMiddle: parameterNameMiddle, ParameterNameRight: parameterNameRight)).ForEach( ( parameter, bldrL1) => bldrL1.Add( $"{parameter.FunctionName}({parameter.ParameterNameLeft}, {parameter.ParameterNameMiddle}, {parameter.ParameterNameRight})"), bldr); return(bldr.ToArray()); }