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()) )); }
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()) )); }
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()) )); }