-
Notifications
You must be signed in to change notification settings - Fork 101
Options
ExpressionEvaluator has a set of options that can modify the way the evaluator works. Here is the list :
Type : Boolean
Default value : true
When true : The code evaluation is case sensitive :
Example :
// Works not
abs(-1) + SIN(3 * pi) - cOS(2 * pI)
// Must be written as this
Abs(-1) + Sin(3 * Pi) - Cos(2 * Pi)
When false : The code evaluation is case insensitive :
Example :
// Works
abs(-1) + SIN(3 * pi) - cOS(2 * pI)
Type : Boolean
Default value : true
When true :
Allow to prefix void methods with Fluid
or Fluent
:
Example :
// Works return 3
List("hello", "bye").FluidAdd("test").Count
When false : Disable the functionality :
Example :
// Generate an exception
List("hello", "bye").FluidAdd("test").Count
See Go fluid with a simple methods prefixing convention
Type : Boolean
Default value : true
When true : Allow to use inline namespaces before type (class). you can use it :
- with new for object creation
- for casting type
- for static call on a class
- for any reference to a type or class for which the namespace is not defined in
evaluator.Namespaces
.
When false :
Disable this functionality. So only the namespaces declared in evaluator.Namespaces
are available.
Type : Boolean
Default value : true
When true :
Allow to create objects with the standard new()
function :
Example :
// Works
new(typeof(MyObject))
When false :
new
as a standard function is forbidden
Example :
// Generate an exception
new(typeof(MyObject))
Type : Boolean
Default value : true
When true :
Allow to create objects with the new
keyword :
Example :
// Works
new MyObject()
When false :
new
as a keyword is forbidden
Example :
// Generate an exception
new MyObject()
Type : Boolean
Default value : true
When true : Allow to call static methods on classes.
Example :
// Works
string.Format("Hello {0}", name)
When false : Calling static methods is forbidden
Example :
// Generate an exception
string.Format("Hello {0}", name)
Type : Boolean
Default value : true
When true : Allow to get the value of a static property on classes.
Example :
// Works
string.Empty
When false : Getting the value of a static property is forbidden.
Example :
// Generate an exception
string.Empty
Type : Boolean
Default value : true
When true : Allow to call methods on objects.
Example :
// Works
myvar.ToString()
When false : Calling instance methods is forbidden.
Example :
// Generate an exception
myvar.ToString()
Type : Boolean
Default value : true
When true : Allow to get the value a property on objects.
Example :
// Works
myStringVar.Length
When false : Getting the value of an instance property is forbidden.
Example :
// Generate an exception
myStringVar.Length
Type : Boolean
Default value : true
When true : Allow to get the value at a specific index of indexed object (Array, List, Dictionnary ...)
Example :
// Works
myArray[2]
myDictionnary["key"]
When false : Indexing is forbidden.
Example :
// Generate exceptions
myArray[2]
myDictionnary["key"]
Type : Boolean
Default value : true
When true : Allow double quotes to evaluate string values ("", $"", @"")
Example :
// Works
"Hello"
$"Hello {name}"
@"C:\Windows"
When false : string values are not evaluated
Example :
// Generate exceptions
"Hello"
$"Hello {name}"
@"C:\Windows"
Type : Boolean
Default value : true
When true : Allow single quotes to evaluate string values ('')
Example :
// Works
'a'
'\n'
','
When false : char values are not evaluated
Example :
// Generate exceptions
'a'
'\n'
','
Type : Boolean
Default value : true
When true : Allow to use the function Evaluate in an expression
Example :
// Works
Evaluate("1+2")
When false : The Evaluate function is blocked. If set to false for security (also ensure that ExpressionEvaluator type is in TypesToBlock list)
Example :
// Generate exceptions
Evaluate("1+2")
Type : Boolean
Default value : true
When true : Allow to assign a value to a variable in the Variable disctionary with (=, +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=, ++ or --)
Example :
// Works
text = "Hello"
i++
When false : Block the assignation of variables
Example :
// Generate exceptions
text = "Hello"
i++
Type : Boolean
Default value : true
When true : Allow to set/modify a property or a field value with (=, +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=, ++ or --)
Example :
// Works
myObject.Text = "Hello"
When false : Block the assignation of fields and properties
Example :
// Generate exceptions
myObject.Text = "Hello"
Type : Boolean
Default value : true
When true : Allow to assign a indexed element like Collections, List, Arrays and Dictionaries with (=, +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=, ++ or --)
Example :
// Works
myArray[2] = "Hello"
myDictionnary["key"]++;
When false : Block the assignation of indexed element
Example :
// Generate exceptions
myArray[2] = "Hello"
myDictionnary["key"]++;
Type : Boolean
Default value : true
When true : Allow to use the function ScriptEvaluate in an expression
Example :
// Works
ScriptEvaluate("value = 1+2;\r\nif(value > 2)\r\nreturn \"OK\";\r\nelse\r\nreturn \"NOK\";")
When false : The ScriptEvaluate function is blocked. If set to false for security (also ensure that ExpressionEvaluator type is in [TypesToBlock]((./C%23-Types-Management#Block-access-of-a-some-type) list)
Example :
// Generate exceptions
ScriptEvaluate("value = 1+2;\r\nif(value > 2)\r\nreturn \"OK\";\r\nelse\r\nreturn \"NOK\";")
Type : OptionOnNoReturnKeywordFoundInScriptAction
Default value : ReturnAutomaticallyLastEvaluatedExpression
Set How to react when the keyword return is not found in a script. when using ScriptEvaluate method
When ReturnAutomaticallyLastEvaluatedExpression : Return the last evaluated expression.
Example :
// For script :
x = 1;
y = 2;
x+y;
// return 3
When ReturnNull :
Return null
Example :
// For script :
x = 1;
y = 2;
x+y;
// return null
When ThrowSyntaxException : Generate an exception
Example :
// This script generate an exception :
x = 1;
y = 2;
x+y;
- Getting Started
- Variables and Functions
- Operators and Keywords
- C# Types Management
- ExpandoObject
- Code Comments Management
- Advanced Customization and Hacking
- Caching
-
Options
- CultureInfoForNumberParsing
- OptionCaseSensitiveEvaluationActive
- OptionVariablesPersistenceCustomComparer
- OptionFluidPrefixingActive
- OptionForceIntegerNumbersEvaluationsAsDoubleByDefault
- OptionNumberParsingDecimalSeparator
- OptionNumberParsingThousandSeparator
- OptionFunctionArgumentsSeparator
- OptionInitializersSeparator
- OptionInlineNamespacesEvaluationRule
- OptionNewFunctionEvaluationActive
- OptionNewKeywordEvaluationActive
- OptionStaticMethodsCallActive
- OptionStaticProperiesGetActive
- OptionInstanceMethodsCallActive
- OptionInstanceProperiesGetActive
- OptionIndexingActive
- OptionStringEvaluationActive
- OptionCharEvaluationActive
- OptionEvaluateFunctionActive
- OptionVariableAssignationActive
- OptionPropertyOrFieldSetActive
- OptionIndexingAssignationActive
- OptionScriptEvaluateFunctionActive
- OptionOnNoReturnKeywordFoundInScriptAction
- OptionScriptNeedSemicolonAtTheEndOfLastExpression
- OptionAllowNonPublicMembersAccess
- Todo List