-
Notifications
You must be signed in to change notification settings - Fork 99
C# Types Management
ExpressionEvaluator manage the following list of C# primary types
- object
- string
- bool/bool?
- byte/byte?
- char/char?
- decimal/decimal?
- double/double?
- short/short?
- int/int?
- long/long?
- sbyte/sbyte?
- float/float?
- ushort/ushort?
- uint/uint?
- ulong/ulong?
- void
Add the ? for nullable types
To resolve types and namespaces ExpressionEvaluator search in in assemblies loaded in the evaluator.Assemblies
list.
By default this list Contains all loaded assemblies in the current AppDomain when the constructor of ExpressionEvaluator is called.
You can easily Clear, Add or Remove assemblies on this list.
By default the following list of namespaces are available :
- System
- System.Linq
- System.IO
- System.Text
- System.Text.RegularExpressions
- System.ComponentModel
- System.Dynamic
- System.Collections
- System.Collections.Generic
- System.Collections.Specialized
- System.Globalization
You can extend or reduce this list :
ExpressionEvaluator evaluator = new ExpressionEvaluator();
evaluator.Namespaces.Add(namespace);
evaluator.Namespaces.Remove(namespaceToRemove);
All types defined in these namespaces are accessibles.
You can also add a specific type :
evaluator.Types.Add(typeof(MyClass));
If you want to block the access of some types (for security reasons for example). You can add the type to block to the TypesToBlock
list.
evaluator.TypesToBlock.Add(typeof(MyCriticalClass));
From version 1.3.2.0 You can also write a the namespace directly inline before the name of the class you want to use. And this as soon as the corresponding assembly is referenced in evaluator.Assemblies
.
doc = new System.Xml.XmlDocument();
url = $"https://www.google.com/search?q={System.Net.WebUtility.UrlEncode("test of request with url encode() ?\")}"
Remark : Inline namespace are useful because it give access to a lot of things without the need to add all namespaces to the evaluator.Namespaces
list.
But it is also a lot slower to execute than the evaluator.Namespaces
way in the case of static access.
Depending on how you use ExpressionEvaluator it can also lead to security issues. So if you need more perfs prefer evaluator.Namespaces
To manage security issues of this functionality see the option OptionInlineNamespacesEvaluationRule (available from version 1.4.38.0). If you have an older version see OptionInlineNamespacesEvaluationActive
- 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