commit | 158fb570db7baa4c8eafe2d57a0690a517eadbb2 | [log] [tgz] |
---|---|---|
author | Dan <danil@danil.cz> | Sat Nov 08 09:03:01 2014 +0100 |
committer | Dan <danil@danil.cz> | Sat Nov 08 09:03:01 2014 +0100 |
tree | 44279bb7c16c0eaf12c865f8e7fec3a28681884f | |
parent | b5ba003f3c91e0bb0ff27eeae4be17166335348b [diff] |
Get rid of the majority of compiler warnings.
##Evalution
Evalution is an evaluation library which allows to inject math expressions in a property during runtime.
Evalution is not an expression interpretator. It's a JIT-compiler. It parses an expression, builds abstract syntax tree and then generates the IL code. The generated code is as fast as a native .Net code.
Currently Evalution supports Int32 and Double types. TimeSpan/DateTime and string operations will be implemented soon.
Evalution is written in F# (only because I want to learn the language :)).
Example:
[Test] public void GeneralTest_Double() { var classBuilder = new ClassBuilder<ClassDouble>() .Setup(x => x.ValueWithExpression, "2.0 + 2.0 * 2.5") .Setup(x => x.DependentValue1, "Value1 * 2.0") .Setup(x => x.DependentValue2, "DependentValue1 * 2.0"); var target = classBuilder.BuildObject(); target.Value1 = 1.5; Assert.AreEqual(7.0, target.ValueWithExpression); // "2.0 + 2.0 * 2.5" Assert.AreEqual(3.0, target.DependentValue1); // "Value1 * 2.0" Assert.AreEqual(6.0, target.DependentValue2); // "DependentValue1 * 2.0" }
There's also a non-generic API:
[Test] public void GeneralTest_NonGeneric() { var classBuilder = new ClassBuilder(typeof(ClassInt32)) .Setup("ValueWithExpression", "2 + 2 * 2") .Setup("DependentValue1", "Value1 * 2") .Setup("DependentValue2", "DependentValue1 * 2"); var target = (ClassInt32)classBuilder.BuildObject(); target.Value1 = 4; Assert.AreEqual(6, target.ValueWithExpression); // "2+2*2" Assert.AreEqual(8, target.DependentValue1); // "Value1*2" Assert.AreEqual(16, target.DependentValue2); // "DependentValue1*2" }