30% OFF - 10th Anniversary discount on new purchases until December 15 with code: ZZZANNIVERSARY10
C# Eval Expression Safe Mode Option
Problem
You want to allow your users to create and evaluate some generic expression. However, you need to limit access on what user can do!
Solution
Use the SafeMode property.
When enabled, the user can only use registered:
- Constructor
- Field
- Method
- Property
Example
var context = new EvalContext(); context.SafeMode = true; context.UnregisterAll(); context.RegisterDefaultAliasSafe(); return context.Eval("1+2");
ZZZ Projects