1. class defines public class company {private string name; Private Employee managingdirector; public string Name {get {return this.name;} Set {this.name = value;} Public Employee managingdirector {get {return this.managingdirector;} Set {this.managingdirector = value;} }} public class Employee {private string name; Private float salary; public string Name {get {return this.name;} Set {this.name = value;} } public float Salary {get {return Salary;} Set {this.salary = value;} }} public class inventor {public inventor (string name, DateTime t, string City) {name = name; Date = t; Placeofbirth = new Placeofbirth () {city=city}; } public DateTime date; public string Name {get; SET Public Placeofbirth Placeofbirth {get; set;} }2. code Implementation Inventor Tesla = new inventor ("Nikola tesla", new DateTime (1856, 7, 9), "serbian"); Tesla. Placeofbirth.city = "smiljan"; String evaluatedname = (string) Expressionevaluator.getvalue (tesla, "Name"); String evaluatedcity = (string) Expressionevaluator.getvalue (tesla, "placeofbirth.city"); Expressionevaluator.setvalue (tesla, "placeofbirth.city", "Novi Sad"); Iexpression exp = Expression.parse ("Name"); String evaluatedName1 = (string) exp. GetValue (tesla, null); 2.1 Literal expressions String HelloWorld = (string) expressionevaluator.getvalue (null, "' Hello Wo Rld ' "); Evals to "Hello world"//string Tonypizza = (string) expressionevaluator.getvalue (null, "' tony\\ ' s Pizza '"); Evals to "Tony ' sdouble avogadrosnumber = (double) expressionevaluator.getvalue (null," 6.0221415E+23 "); int maxValue = ( Int) Expressionevaluator.getvalue (null, "0x7FFFFFFF"); Evals to 2147483647DateTime birthday = (DateTime) expressionevaluator.getvalue (null, "date (' 1974/08/24 ')");D atetime Exactbirthday = (DateTime) expressionevaluator.getvalue (null, "date (' 19740824t131030 ', ' YYYYMMDDTHHMMSS ')"); bool TrueValue = (bool) Expressionevaluator.getvalue (null, "true"); Object nullvalue = Expressionevaluator.getvalue (null, "null"); 2.2 Properties, Arrays, Lists, dictionaries, indexersint Year = (int) Expressionevaluator.getvalue (tesla, "DOB. Year ")); 1856 String city = (string) Expressionevaluator.getvalue (pupin, "placeofbirth.city"); "idvor"//inventions Array String invention = (string) Expressionevaluator.getvalue (tesla, "inventions[3]"); "induction motor"//members List String name = (string) Expressionevaluator.getvalue (ieee, "members[0"). Name "); "Nikola Tesla"//List and Array navigation string invention = (string) Expressionevaluator.getvalue (ieee, "members[0"). inventions[6] ")//" wireless//Officer's Dictionary inventor Pupin = (inventor) ExpressionEvaluator. GetValue (ieee, "officers[' President ')"; String city = (string) Expressionevaluator.getvalue (ieee, "officers[" President ']. Placeofbirth.city "); "idvor" expressionevaluator.setvalue (ieee, "officers[' Advisors '][0]. Placeofbirth.country "," Croatia ");//index Indexer public class bar{private int[] numbers = new int[] {1, 2, 3}; public int thi S[int index] {get {return numbers[index]; } Set {numbers[index] = value; }} Bar B = new bar (); int val = (int) expressionevaluator.getvalue (bar, "[1]")//evaluated to 2 expressionevaluator.setvalue (bar, "[1]", 3); Set value to 32.3 methods//string literal
char[] chars = (char[]) expressionevaluator.getvalue (null, "' test '). ToCharArray (1, 2) ")//' t ', ' e '
Date literal
int year = (int) expressionevaluator.getvalue (null, "date (' 1974/08/24 '). AddYears (31). Year ")//2005
Object usage, calculate age of Tesla navigating from the IEEE Society.
Expressionevaluator.getvalue (ieee, "members[0"). Getage (date (' 2005-01-01 '))//149 (eww. A big anniversary is
2.4 Operation
Expressionevaluator.getvalue (null, "2 = = 2")//true
Expressionevaluator.getvalue (null, "date (' 1974-08-24 ')! = datetime.today")//true
Expressionevaluator.getvalue (null, "2 < -5.0")//false
Expressionevaluator.getvalue (null, "datetime.today <= date (' 1974-08-24 ')")//false
Expressionevaluator.getvalue (null, "' test ' >= ' test '")//true
Foocolor fcolor = new Foocolor (); Expressionevaluator.setvalue (fcolor, "Color", knowncolor.blue); BOOL TrueValue = (bool) Expressionevaluator.getvalue (fcolor, "Color = = knowncolor.blue"); True
2.5 expressions
Expressionevaluator.getvalue (null, "3 in {1, 2, 3, 4, 5}")//true
Expressionevaluator.getvalue (null, "' Abc ' like ' [a-z]b* '")//true
Expressionevaluator.getvalue (null, "' Abc ' like '? '")//false
Expressionevaluator.getvalue (null, "1 between {1, 5}")//true
Expressionevaluator.getvalue (null, "' EFG ' between {' ABC ', ' XYZ '}")//true
Expressionevaluator.getvalue (null, "' xyz ' is Int")//false
Expressionevaluator.getvalue (null, "{1, 2, 3, 4, 5} is IList")//true
Expressionevaluator.getvalue (null, "' 5.0067 ' matches ' ^-?\\d+ (\\.\\d{2}) ')//false
Expressionevaluator.getvalue (null, @ "' 5.00 ' matches ' ^-?\d+ (\.\d{2})? $ '")//true
2.6 Logical Operators
BOOL Falsevalue = (bool) expressionevaluator.getvalue (null, "true and false"); False
string expression = @ "ismember (' Nikola Tesla ') and IsMember (' Mihajlo Pupin ')";
BOOL TrueValue = (bool) Expressionevaluator.getvalue (ieee, expression); True
BOOL TrueValue = (bool) expressionevaluator.getvalue (null, "true or false"); True
string expression = @ "ismember (' Nikola Tesla ') or IsMember (' Albert Einstien ')";
BOOL TrueValue = (bool) Expressionevaluator.getvalue (ieee, expression); True
Not
BOOL Falsevalue = (bool) Expressionevaluator.getvalue (null, "!true");
And And not
string expression = @ "ismember (' Nikola Tesla ') and! IsMember (' Mihajlo Pupin ') ";
BOOL Falsevalue = (bool) Expressionevaluator.getvalue (ieee, expression);
2.7-bit arithmetic
and
int result = (int) Expressionevaluator.getvalue (null, "1 and 3"); 1 & 3
or int result = (int) Expressionevaluator.getvalue (null, "1 or 3"); 1 | 3
XOR int result = (int) Expressionevaluator.getvalue (null, "1 xor 3"); 1 ^ 3
not int result = (int) Expressionevaluator.getvalue (null, "! 1"); To
2.8 Mathematical Operations
Addition
int a = (int) expressionevaluator.getvalue (null, "1 + 1"); 2
String teststring = (string) expressionevaluator.getvalue (null, "' Test ' + ' + ' + ' string '); ' Test string '
DateTime dt = (datetime) expressionevaluator.getvalue (null, "date (' 1974-08-24 ') + 5"); 8/29/1974
subtraction int four = (int) Expressionevaluator.getvalue (null, "1-3"); 4
Decimal Dec = (decimal) Expressionevaluator.getvalue (null, "1000.00m-1e4"); 9000.00
TimeSpan ts = (timespan) expressionevaluator.getvalue (null, "date (' 2004-08-14 ')-date (' 1974-08-24 ')"); 10948.00:00:00//
int six = (int) expressionevaluator.getvalue (null, "-2 *-3"); 6
int twentyfour = (int) expressionevaluator.getvalue (null, "2.0 * 3e0 * 4"); 24
Division int minustwo = (int) Expressionevaluator.getvalue (null, "6/3"); -2
int one = (int) expressionevaluator.getvalue (null, "8.0/4e0/2"); 1
modulus int three = (int) expressionevaluator.getvalue (null, "7 4"); 3
int one = (int) expressionevaluator.getvalue (null, "8.0% 5e0 2"); 1
int sixteen = (int) expressionevaluator.getvalue (null, "-2 ^ 4"); 16
Operator Precedence
int minusfortyfive = (int) Expressionevaluator.getvalue (null, "1+2-3*8^2/2/2"); -45
2.9 Assignment
Inventor inventor = new inventor ();
String Aleks = (string) expressionevaluator.getvalue (inventor, "Name = ' Aleksandar Seovic '");
DateTime dt = (datetime) expressionevaluator.getvalue (inventor, "DOB = Date (' 1974-08-24 ')");
Set the vice president of the Society
Inventor Tesla = (inventor) expressionevaluator.getvalue (ieee, "officers[' VP '] = members[0]");
3.0 List of expressions
Perform property assignments and then return the Name Property.
String Pupin = (string) Expressionevaluator.getvalue (ieee. members, "([1]. placeofbirth.city = ' Beograd '; [1]. Placeofbirth.country = ' Serbia '; [1]. Name)); Pupin = "mihajlo pupin"
3.1 Types
Expressionevaluator.getvalue (null, "1 is Int")
Expressionevaluator.getvalue (null, "datetime.today")
Expressionevaluator.getvalue (null, "new string[" {' abc ', ' EFG '} ")
Type Datetype = (type) expressionevaluator.getvalue (null, "T (system.datetime)")
Type Evaltype = (type) expressionevaluator.getvalue (null, "T (Spring.Expressions.ExpressionEvaluator, Spring.core)")
BOOL TrueValue = (bool) Expressionevaluator.getvalue (tesla, "T (system.datetime) = = DOB. GetType () ")
3.2 Type Registration
Typeregistry.registertype ("society", typeof (society));
Inventor Pupin = (inventor) expressionevaluator.getvalue (ieee, "officers[society.president]");
3.3 Variables
IDictionary VARs = new Hashtable ();
vars["newName"] = "Mike Tesla";
Expressionevaluator.getvalue (tesla, "Name = #newName", vars));
Expressionevaluator.getvalue (tesla, "{#oldName = Name; Name = ' Nikola Tesla '} ", vars);
String oldname = (string) vars["oldname"]; Mike Tesla
vars["prez"] = "president";
Inventor Pupin = (inventor) expressionevaluator.getvalue (ieee, "officers[#prez]", vars);
Spring.net expression Parsing ExpressionEvaluator