예제 #1
0
        static void Main(string[] args)
        {
            dynamic dynamicobj2 = new DynamicType2();

            dynamicobj2.Call();
            Console.Read();
        }
예제 #2
0
        // 重写响应成员调用方法
        public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args)
        {
            // 获得真正的对象
            DynamicType2 target       = (DynamicType2)base.Value;
            Expression   self         = Expression.Convert(base.Expression, typeof(DynamicType2));
            var          restrictions = BindingRestrictions.GetInstanceRestriction(self, target);

            // 输出绑定方法名
            Console.WriteLine(binder.Name + " 方法被调用了");
            return(new DynamicMetaObject(self, restrictions));
        }
예제 #3
0
 internal Metadynamic(Expression expression, DynamicType2 value)
     : base(expression, BindingRestrictions.Empty, value)
 {
 }