Ejemplo n.º 1
0
        public void TestLambdaVB()
        {
            var c = new CodeDomGenerator();

            c.AddNamespace("Samples")
            .AddClass("cls")
            .AddMethod(MemberAttributes.Public | MemberAttributes.Static, (bool f) => "foo",
                       Emit.declare("a", () => CodeDom.Lambda(() => 1)),
                       Emit.declare("c", () => CodeDom.Lambda((int aa) => aa + 10,
                                                              new LambdaParam(typeof(int), "aa"))),
                       Emit.stmt((int a) => CodeDom.CallDelegate(CodeDom.VarRef("c").Call("Compile"))(
                                     CodeDom.CallDelegate(CodeDom.VarRef("a").Call("Compile"))
                                     ))
                       )
            ;


            c.AddReference("System.Core.dll");

            Console.WriteLine(c.GenerateCode(CodeDomGenerator.Language.VB));

            var ass = c.Compile(CodeDomGenerator.Language.VB);

            Assert.IsNotNull(ass);

            Type TestClass = ass.GetType("Samples.cls");

            Assert.IsNotNull(TestClass);
        }