Beispiel #1
0
        public static async Task Main()
        {
            var p = new Program();

            dynamic tm2 = DynamicObject.CreateProxy(new TestModel2());
            dynamic tm3 = DynamicObject.CreateProxy(new TestModel2());

            dynamic m         = DynamicObject.CreateProxy(new TestModel());
            var     proxyType = (Type)m.GetType();

            m.run_proxy <Program>();
            m.Run0_1 <Program>();

            // m.Run0_2(ref p); // DynamicMethod는 포인터를 지원하지 않음.
            var Run0_2     = proxyType.GetMethod("Run0_2").MakeGenericMethod(typeof(Program));
            var Run0_2_Arg = new object[] { p };

            Run0_2 !.Invoke(m, Run0_2_Arg);

            m.Run1();

            m.Run2();

            await m.Run3();

            await m.Run3_1();

            Console.WriteLine(m.Run4());

            Console.WriteLine(await m.Run5());

            Console.WriteLine(await m.Run6());

            await foreach (var v in (IAsyncEnumerable <int>)m.Run7())
            {
                Console.WriteLine($"Run7: {v}");
            }

            await foreach (var v in await(Task <IAsyncEnumerable <int> >) m.Run7_1())
            {
                Console.WriteLine($"Run7_1: {v}");
            }

            await foreach (var v in (IAsyncEnumerable <int>)m.Run8())
            {
                Console.WriteLine($"Run8: {v}");
            }

            var console = (IConsole)m;

            console.Write("Explicit interface method test\n");
            console.WriteLine("Implicit interface method test");

            var console2 = (IConsole2)m;

            console2.Write("Explicit interface method test\n");
            console2.WriteLine("Implicit interface method test");
        }