public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder) { ContractUtils.RequiresNotNull(binder, "binder"); int index = Value.Class.GetValueIndex(binder.Name, binder.IgnoreCase, Value); Expression tryDelete = Expression.Call( typeof(RuntimeOps).GetMethod("ExpandoTryDeleteValue"), GetLimitedSelf(), Expression.Constant(Value.Class, typeof(object)), Expression.Constant(index), Expression.Constant(binder.Name), Expression.Constant(binder.IgnoreCase) ); DynamicMetaObject fallback = binder.FallbackDeleteMember(this); DynamicMetaObject target = new DynamicMetaObject( Expression.IfThen(Expression.Not(tryDelete), fallback.Expression), fallback.Restrictions ); return(AddDynamicTestAndDefer(binder, Value.Class, null, target)); }
/// <summary> /// Provides the implementation of deleting a member. Derived classes can override /// this method to customize behavior. When not overridden the call site requesting the /// binder determines the behavior. /// </summary> /// <param name="binder">The binder provided by the call site.</param> /// <returns>true if the operation is complete, false if the call site should determine behavior.</returns> public virtual bool TryDeleteMember(DeleteMemberBinder binder) { return(false); }
/// <summary> /// Performs the binding of the dynamic delete member operation. /// </summary> /// <param name="binder">An instance of the <see cref="DeleteMemberBinder"/> that represents the details of the dynamic operation.</param> /// <returns>The new <see cref="DynamicMetaObject"/> representing the result of the binding.</returns> public virtual DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder) { ContractUtils.RequiresNotNull(binder, "binder"); return(binder.FallbackDeleteMember(this)); }