This project has moved and is read-only. For the latest updates, please go here.


Feb 26, 2014 at 4:16 PM
Edited Feb 26, 2014 at 4:27 PM
Hi.. First of all very nice tool. thanks for sharing it with us.

Is this a bug?. For example the following code:
  var c = new CompiledExpression() { StringToParse = "Convert.ToBoolean(result)==true" };
  object obj = true;
  c.RegisterType("result", obj);
  var result = c.Eval();
  1. Thrown me error exception "Unable to cast object of type 'System.Boolean' to type 'System.Type'." then I fixed the error changes from "_tokenQueue.Enqueue(new Token() { Value = "(" + token + ")", IsCast = true, Type = (Type)TypeRegistry[token] });" to "_tokenQueue.Enqueue(new Token() { Value = "(" + token + ")", IsCast = true, Type = TypeRegistry[token].GetType() });" on the line 550, file Parser.cs. but the next error were " Parenthesis mismatch"
These errors doesn't happened with previous version..

I´m from colombia, so sorry about my english. :D..
Feb 27, 2014 at 6:35 AM
It's not exactly a bug.

I never designed RegisterType to be used to register primitive variables. What you should do is wrap your variables in a class like this:
    public class objHolder
        public bool result { get; set; }
And in your main code
            var cc = new CompiledExpression() { StringToParse = "Convert.ToBoolean(obj.result)==true" };
            object obj = new objHolder() { result = true };
            cc.RegisterType("obj", obj);
            var result = cc.Eval();
It's either you use RegisterType on a class instance that holds your data, or use ScopeCompile and generate a function where you pass that class instance.