The language predefines the primitive data types, and reserved keywords name them.
The Dynamic Expresso manages the following list of C# primary types.
You can add additional types by using the Interpreter.Reference
method, as shown below.
public static void Example1()
{
Interpreter interpreter = new Interpreter();
interpreter.Reference(typeof(Customer));
interpreter.SetVariable("customer", new Customer()
{
FirstName = "Mark",
LastName = "Upston",
BirthDate = new DateTime(1977, 12, 10)
});
string expression = "customer.FirstName + ' ' + customer.LastName";
var result = interpreter.Eval(expression);
Console.WriteLine(result);
}
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime BirthDate { get; set; }
}
Now when you run the above code, you will see the following output.
Mark Upston