|
22 | 22 | namespace CodingSeb.ExpressionEvaluator
|
23 | 23 | {
|
24 | 24 | /// <summary>
|
25 |
| - /// This class allow to evaluate a string math or pseudo C# expression |
| 25 | + /// This class allow to evaluate a string math or pseudo C# expression |
26 | 26 | /// </summary>
|
27 | 27 | public partial class ExpressionEvaluator
|
28 | 28 | {
|
@@ -653,8 +653,8 @@ public string OptionNumberParsingThousandSeparator
|
653 | 653 | public bool OptionFluidPrefixingActive { get; set; } = true;
|
654 | 654 |
|
655 | 655 | /// <summary>
|
656 |
| - /// if <c>true</c> allow the use of inline namespace (Can be slow, and is less secure). |
657 |
| - /// if <c>false</c> unactive inline namespace (only namespaces in Namespaces list are available). |
| 656 | + /// if <c>true</c> allow the use of inline namespace (Can be slow, and is less secure). |
| 657 | + /// if <c>false</c> unactive inline namespace (only namespaces in Namespaces list are available). |
658 | 658 | /// By default : true
|
659 | 659 | /// </summary>
|
660 | 660 | public bool OptionInlineNamespacesEvaluationActive { get; set; } = true;
|
@@ -744,7 +744,7 @@ public bool OptionNewFunctionEvaluationActive
|
744 | 744 |
|
745 | 745 | /// <summary>
|
746 | 746 | /// If <c>true</c> Evaluate function is callables in an expression. If <c>false</c> Evaluate is not callable.
|
747 |
| - /// By default : true |
| 747 | + /// By default : true |
748 | 748 | /// if set to false for security (also ensure that ExpressionEvaluator type is in TypesToBlock list)
|
749 | 749 | /// </summary>
|
750 | 750 | public bool OptionEvaluateFunctionActive { get; set; } = true;
|
@@ -772,7 +772,7 @@ public bool OptionNewFunctionEvaluationActive
|
772 | 772 |
|
773 | 773 | /// <summary>
|
774 | 774 | /// If <c>true</c> ScriptEvaluate function is callables in an expression. If <c>false</c> Evaluate is not callable.
|
775 |
| - /// By default : true |
| 775 | + /// By default : true |
776 | 776 | /// if set to false for security (also ensure that ExpressionEvaluator type is in TypesToBlock list)
|
777 | 777 | /// </summary>
|
778 | 778 | public bool OptionScriptEvaluateFunctionActive { get; set; } = true;
|
@@ -1394,7 +1394,7 @@ void forAction(int index)
|
1394 | 1394 |
|
1395 | 1395 | bool executed = false;
|
1396 | 1396 |
|
1397 |
| - if (TryParseStringAndParenthisAndCurlyBrackets(ref i)){} |
| 1397 | + if (TryParseStringAndParenthisAndCurlyBrackets(ref i)) { } |
1398 | 1398 | else if (script.Length - i > 2 && script.Substring(i, 3).Equals("';'"))
|
1399 | 1399 | {
|
1400 | 1400 | i += 2;
|
@@ -1454,7 +1454,7 @@ public T Evaluate<T>(string expression)
|
1454 | 1454 |
|
1455 | 1455 | private IList<ParsingMethodDelegate> parsingMethods;
|
1456 | 1456 |
|
1457 |
| - protected virtual IList<ParsingMethodDelegate> ParsingMethods => parsingMethods ?? (parsingMethods = new List<ParsingMethodDelegate>() |
| 1457 | + protected virtual IList<ParsingMethodDelegate> ParsingMethods => parsingMethods ?? (parsingMethods = new List<ParsingMethodDelegate>() |
1458 | 1458 | {
|
1459 | 1459 | EvaluateCast,
|
1460 | 1460 | EvaluateNumber,
|
@@ -1809,7 +1809,7 @@ protected virtual bool EvaluateVarOrFunc(string expression, Stack<object> stack,
|
1809 | 1809 |
|
1810 | 1810 | try
|
1811 | 1811 | {
|
1812 |
| - if(obj is NullConditionalNullValue) |
| 1812 | + if (obj is NullConditionalNullValue) |
1813 | 1813 | {
|
1814 | 1814 | stack.Push(obj);
|
1815 | 1815 | }
|
@@ -1851,7 +1851,7 @@ protected virtual bool EvaluateVarOrFunc(string expression, Stack<object> stack,
|
1851 | 1851 | {
|
1852 | 1852 | if (dictionaryObject[varFuncName] is InternalDelegate internalDelegate)
|
1853 | 1853 | stack.Push(internalDelegate(oArgs.ToArray()));
|
1854 |
| - else if(dictionaryObject[varFuncName] is Delegate del) |
| 1854 | + else if (dictionaryObject[varFuncName] is Delegate del) |
1855 | 1855 | stack.Push(del.DynamicInvoke(oArgs.ToArray()));
|
1856 | 1856 | }
|
1857 | 1857 | else if (objType.GetProperty(varFuncName, InstanceBindingFlag) is PropertyInfo instancePropertyInfo
|
@@ -2250,7 +2250,7 @@ protected virtual bool EvaluateVarOrFunc(string expression, Stack<object> stack,
|
2250 | 2250 | {
|
2251 | 2251 | if (Variables.ContainsKey(varFuncName) && Variables[varFuncName] is StronglyTypedVariable stronglyTypedVariable)
|
2252 | 2252 | {
|
2253 |
| - if(cusVarValueToPush == null && stronglyTypedVariable.Type.IsValueType && Nullable.GetUnderlyingType(stronglyTypedVariable.Type) == null) |
| 2253 | + if (cusVarValueToPush == null && stronglyTypedVariable.Type.IsValueType && Nullable.GetUnderlyingType(stronglyTypedVariable.Type) == null) |
2254 | 2254 | {
|
2255 | 2255 | throw new ExpressionEvaluatorSyntaxErrorException($"Can not cast null to {stronglyTypedVariable.Type} because it's not a nullable valueType");
|
2256 | 2256 | }
|
@@ -2417,11 +2417,11 @@ protected virtual bool EvaluateOperators(string expression, Stack<object> stack,
|
2417 | 2417 |
|
2418 | 2418 | Match match = Regex.Match(expression.Substring(i), regexPattern, optionCaseSensitiveEvaluationActive ? RegexOptions.None : RegexOptions.IgnoreCase);
|
2419 | 2419 |
|
2420 |
| - if(match.Success) |
| 2420 | + if (match.Success) |
2421 | 2421 | {
|
2422 | 2422 | string op = match.Value;
|
2423 | 2423 | stack.Push(operatorsDictionary[op]);
|
2424 |
| - i+= op.Length - 1; |
| 2424 | + i += op.Length - 1; |
2425 | 2425 | return true;
|
2426 | 2426 | }
|
2427 | 2427 |
|
@@ -2572,7 +2572,6 @@ protected virtual bool EvaluateIndexing(string expression, Stack<object> stack,
|
2572 | 2572 |
|
2573 | 2573 | dynamic right = Evaluate(innerExp.ToString());
|
2574 | 2574 | ExpressionOperator op = indexingBeginningMatch.Length == 2 ? ExpressionOperator.IndexingWithNullConditional : ExpressionOperator.Indexing;
|
2575 |
| - |
2576 | 2575 |
|
2577 | 2576 | if (OptionForceIntegerNumbersEvaluationsAsDoubleByDefault && right is double && Regex.IsMatch(innerExp.ToString(), @"^\d+$"))
|
2578 | 2577 | right = (int)right;
|
@@ -2995,7 +2994,7 @@ protected virtual MethodInfo GetRealMethod(ref Type type, ref object obj, string
|
2995 | 2994 | .MakeGenericMethod(parameterType.GetGenericArguments());
|
2996 | 2995 | modifiedArgs[a] = Delegate.CreateDelegate(parameterType, de, encapsMethod);
|
2997 | 2996 | }
|
2998 |
| - else if(paramTypeName.StartsWith("Action") |
| 2997 | + else if (paramTypeName.StartsWith("Action") |
2999 | 2998 | && modifiedArgs[a] is InternalDelegate)
|
3000 | 2999 | {
|
3001 | 3000 | InternalDelegate led = modifiedArgs[a] as InternalDelegate;
|
@@ -3047,7 +3046,7 @@ protected virtual MethodInfo MakeConcreteMethodIfGeneric(MethodInfo methodInfo,
|
3047 | 3046 | {
|
3048 | 3047 | if (genericsTypes.Equals(string.Empty))
|
3049 | 3048 | {
|
3050 |
| - if(inferedGenericsTypes != null && inferedGenericsTypes.Length == methodInfo.GetGenericArguments().Length) |
| 3049 | + if (inferedGenericsTypes != null && inferedGenericsTypes.Length == methodInfo.GetGenericArguments().Length) |
3051 | 3050 | {
|
3052 | 3051 | return methodInfo.MakeGenericMethod(inferedGenericsTypes);
|
3053 | 3052 | }
|
@@ -3722,7 +3721,7 @@ public override int GetHashCode()
|
3722 | 3721 |
|
3723 | 3722 | public bool Equals(ExpressionOperator otherOperator)
|
3724 | 3723 | {
|
3725 |
| - return otherOperator!= null && OperatorValue == otherOperator.OperatorValue; |
| 3724 | + return otherOperator != null && OperatorValue == otherOperator.OperatorValue; |
3726 | 3725 | }
|
3727 | 3726 | }
|
3728 | 3727 |
|
|
0 commit comments