public void Reference() { using (var test = Dynasor.Compile <Creator <TestClass> >(@"TestClass test() => new TestClass(""123"");")) { var d = test.Method(); Assert.IsInstanceOfType(d, typeof(TestClass)); Assert.AreEqual(d.ToString(), "123"); } }
public void TestMethod1() { try { var add = Dynasor.Compile("int add(int a, int b)=>a+b;"); Assert.AreEqual(add(1, 2), 3); } catch (CompilationException) { Assert.Fail(); } }
public void TestMethod2() { try { using (var add = Dynasor.Compile <Func <int, int, int> >("int add(int a, int b)=>a+b;")) Assert.AreEqual(add.Method(1, 2), 3); } catch (CompilationException) { Assert.Fail(); } }
static void Main(string[] args) { var sw = new Stopwatch(); var k = "int s(int vb) => vb + {0} ;"; var rnd = new Random(Guid.NewGuid().GetHashCode()); for (int i = 0; i < 10; i++) { var s = string.Format(k, rnd.Next()); sw.Start(); using (var r = Dynasor.Compile <Func <int, int> >(s)) { sw.Stop(); Console.WriteLine(sw.Elapsed); Console.WriteLine(r.Method(20)); } sw.Reset(); } Console.ReadKey(); return; }