Exemplo n.º 1
0
        private static void Test(System.Reflection.Emit.TypeBuilder xExtensions, ref foo f)
        {
            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201401/20140118
            // X:\jsc.svn\examples\rewrite\Test\TestStackRewriter\TestStackRewriter\Program.cs

            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201401/20140115/xlsx
            f.m = xExtensions.DefineMethod("AsDataTable",
                default(MethodAttributes),
                null,
                // parameter types
                // there is a fault here.
                new[] { typeof(IEnumerable<>).MakeGenericType(f.x) }
            );
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201401/20140115/xlsx

            var a = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("foo"), System.Reflection.Emit.AssemblyBuilderAccess.Save);
            var e = new { Module = a.DefineDynamicModule("foo") };


            var xExtensions = e.Module.DefineType("Extensions");
            var xRow = e.Module.DefineType("Row");
            Console.WriteLine("define xExtensionsAsDataTable");


            var f = new foo { x = xRow };
            Test(xExtensions, ref f);
        }