public void StaticMemberDynamicWrapperTest()
        {
            dynamic s = new StaticMemberDynamicWrapper(typeof(string));
            var     r = s.Concat("A", "B");

            Console.WriteLine(r);
        }
Пример #2
0
        public void Dynamic_InvokeStaticMember()
        {
            dynamic stringType = new StaticMemberDynamicWrapper(typeof(string));
            var     r          = stringType.Concat("A", "B");   // 动态调用String的静态Concat方法

            Assert.Equal("AB", r);

            dynamic d = new StaticMemberDynamicWrapper(this.GetType());

            Assert.Equal(d.StaticMember, 1);
        }
        private static void DynamicStaticInvocations()
        {
            dynamic staticType = new StaticMemberDynamicWrapper(typeof(String));

            Console.WriteLine(staticType.Concat("A", "B"));

            staticType = new StaticMemberDynamicWrapper(typeof(StaticTestType));
            Console.WriteLine(staticType.Method(5));
            staticType.Field = DateTime.Now;
            Console.WriteLine(staticType.Field);
            staticType.Property = Guid.NewGuid();
            Console.WriteLine(staticType.Property);
        }
      private static void DynamicStaticInvocations() {
         dynamic staticType = new StaticMemberDynamicWrapper(typeof(String));
         Console.WriteLine(staticType.Concat("A", "B"));

         staticType = new StaticMemberDynamicWrapper(typeof(StaticTestType));
         Console.WriteLine(staticType.Method(5));
         staticType.Field = DateTime.Now;
         Console.WriteLine(staticType.Field);
         staticType.Property = Guid.NewGuid();
         Console.WriteLine(staticType.Property);
      }
        public void TryInvokeMemberTest()
        {
            dynamic dyn = new StaticMemberDynamicWrapper(typeof(Person));

            dyn.StaticMethod();
        }