In response to the runtime evaluation, I've created a quick and dirty
expression evaluator class[1]. Please feel free to contact me directly
with suggestions/bugs. It works in two ways:
Slow (compilation of a single expressions at once):
int x = Evaluator.EvaluateToInteger("(30 + 4) * 2");
string s = Evaluator.EvaluateToString("\"Hello \" + \"There\"");
bool b Evaluator.EvaluateToBool("30 == 40");
DataSet ds = (DataSet) Evaluator.EvaluateToObject("new DataSet()");
Faster (compilation of all into one CodeDOM):
EvaluatorItem[] items = {
new EvaluatorItem(typeof(int), "(30 + 4) * 2", "GetNumber"),
new EvaluatorItem(typeof(string), "\"Hello \" + \"There\"",
"GetString"),
new EvaluatorItem(typeof(bool), "30 == 40", "GetBool"),
new EvaluatorItem(typeof(object), "new DataSet()", "GetDataSet")
};
Evaluator eval = new Evaluator(items);
int x = eval.EvaluateInt("GetNumber");
string s = eval.EvaluateString("GetString");
bool b = eval.EvaluateBool("GetBool");
DataSet ds = (DataSet) eval.Evaluate("GetDataSet");
Thanks,
Shawn Wildermuth
[EMAIL PROTECTED]
http://adoguy.com
http://shawnwildermuth.com
[1] http://adoguy.com/ADONETExamples/evaluator.zip
http://adoguy.com/ADONETExamples/
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.