Exemplo n.º 1
0
 public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
 {
     return(new DynamicMetaObject(
                Expression.Call(
                    Utils.Convert(Expression, typeof(PythonModule)),
                    typeof(PythonModule).GetMethod("__delattr__"),
                    PythonContext.GetCodeContext(binder),
                    Expression.Constant(binder.Name)
                    ),
                BindingRestrictions.GetTypeRestriction(Expression, Value.GetType())
                ));
 }
Exemplo n.º 2
0
            public override DynamicMetaObject BindSetMember(SetMemberBinder binder, DynamicMetaObject value)
            {
                Debug.Assert(value.Value != Uninitialized.Instance);

                return(new DynamicMetaObject(
                           Expression.Block(
                               Expression.Call(
                                   Utils.Convert(Expression, typeof(PythonModule)),
                                   typeof(PythonModule).GetMethod("__setattr__"),
                                   PythonContext.GetCodeContext(binder),
                                   Expression.Constant(binder.Name),
                                   Expression.Convert(value.Expression, typeof(object))
                                   ),
                               Expression.Convert(value.Expression, typeof(object))
                               ),
                           BindingRestrictions.GetTypeRestriction(Expression, Value.GetType())
                           ));
            }
Exemplo n.º 3
0
            private DynamicMetaObject GetMemberWorker(DynamicMetaObjectBinder binder, DynamicMetaObject codeContext)
            {
                string name = GetGetMemberName(binder);
                var    tmp  = Expression.Variable(typeof(object), "res");

                return(new DynamicMetaObject(
                           Expression.Block(
                               new[] { tmp },
                               Expression.Condition(
                                   Expression.Call(
                                       typeof(PythonOps).GetMethod("ModuleTryGetMember"),
                                       PythonContext.GetCodeContext(binder),
                                       Utils.Convert(Expression, typeof(PythonModule)),
                                       Expression.Constant(name),
                                       tmp
                                       ),
                                   tmp,
                                   Expression.Convert(GetMemberFallback(this, binder, codeContext).Expression, typeof(object))
                                   )
                               ),
                           BindingRestrictions.GetTypeRestriction(Expression, Value.GetType())
                           ));
            }