Represents the dynamic delete member operation at the call site, providing the binding semantic and the details about the operation.
Inheritance: DynamicMetaObjectBinder
Exemplo n.º 1
0
        public override bool TryDeleteMember(DeleteMemberBinder binder)
        {
            var name = binder.Name;
            if (!_values.ContainsKey(name))
                return false;

            _values.Remove(name);
            return true;
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Provides the implementation for operations that delete an object member. This method is not intended for use in C#
        ///     or Visual Basic.
        /// </summary>
        /// <param name="binder">Provides information about the deletion.</param>
        /// <returns>
        ///     true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the
        ///     language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
        /// </returns>
        public override bool TryDeleteMember(DeleteMemberBinder binder)
        {
            string name = binder.Name;

            if (!_Dictionary.ContainsKey(name))
            {
                return(false);
            }

            _Dictionary.Remove(name);

            return(true);
        }
Exemplo n.º 3
0
 public override Meta BindDeleteMember(DeleteMemberBinder binder)
 {
     return new Meta(
         Et.Call(
             EtUtils.Cast<IObj>(this.Expression),
             IObjMethods.MiDelete,
             Et.Constant(binder.Name)
         ),
         Restrict.GetTypeRestriction(
             this.Expression,
             this.LimitType
         )
     );
 }
Exemplo n.º 4
0
            public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
            {
                if (IsOverridden(nameof(DynamicObject.TryDeleteMember)))
                {
                    return(CallMethodNoResult(
                               nameof(DynamicObject.TryDeleteMember),
                               binder,
                               s_noArgs,
                               (MetaDynamic @this, DeleteMemberBinder b, DynamicMetaObject e) => b.FallbackDeleteMember(@this, e)
                               ));
                }

                return(base.BindDeleteMember(binder));
            }
Exemplo n.º 5
0
            public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
            {
                Fallback fallback = null;

                if (!this.IsOverridden("TryDeleteMember"))
                {
                    return(base.BindDeleteMember(binder));
                }
                if (fallback == null)
                {
                    fallback = e => binder.FallbackDeleteMember(this, e);
                }
                return(this.CallMethodNoResult("TryDeleteMember", binder, NoArgs, fallback));
            }
Exemplo n.º 6
0
        /// <summary>
        /// Implementation of delete member
        /// </summary>
        /// <param name="binder">The binder</param>
        /// <returns>True if member could be deleted</returns>
        public override bool TryDeleteMember(System.Dynamic.DeleteMemberBinder binder)
        {
            DataNode n = GetNodeNoThrow(binder.Name);

            if (n != null)
            {
                n.RemoveNode();
                return(true);
            }
            else
            {
                return(base.TryDeleteMember(binder));
            }
        }
Exemplo n.º 7
0
            public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
            {
                if (IsOverridden(DynamicObjectTryDeleteMember))
                {
                    return(CallMethodNoResult(
                               DynamicObjectTryDeleteMember,
                               binder,
                               _noArgs,
                               (@this, b, e) => b.FallbackDeleteMember(@this, e)
                               ));
                }

                return(base.BindDeleteMember(binder));
            }
Exemplo n.º 8
0
            public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
            {
                ArgumentNullException.ThrowIfNull(binder);

                int index = Value.Class.GetValueIndex(binder.Name, binder.IgnoreCase, Value);

                Expression tryDelete = Expression.Call(
                    s_expandoTryDeleteValue,
                    GetLimitedSelf(),
                    Expression.Constant(Value.Class, typeof(object)),
                    AstUtils.Constant(index),
                    Expression.Constant(binder.Name),
                    AstUtils.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));
            }
Exemplo n.º 9
0
            public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
            {
                ContractUtils.RequiresNotNull(binder, nameof(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));
            }
Exemplo n.º 10
0
        private DispatchResult DispatchDeleteMember(DeleteMemberBinder binder, Object @this)
        {
            var old_value = Value;
            Value = @this;

            try
            {
                try
                {
                    try
                    {
                        DeleteMember(binder);
                        return Succeed();
                    }
                    catch (FallbackException)
                    {
                        var dynamic_object = Value as IDynamicObject;
                        if (dynamic_object != null) { dynamic_object.DeleteMember(binder); return Succeed(); }
                        else throw;
                    }
                }
                catch (FallbackException)
                {
                    return Fail();
                }
                catch (Exception ex)
                {
                    if (WrapExceptions)
                    {
                        var bind_args = new OrderedDictionary<String, Object>();
                        bind_args.Add("this", @this);
                        throw new BindException(binder, bind_args, ex);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            finally
            {
                Value = old_value;
            }
        }
 public virtual new bool TryDeleteMember(DeleteMemberBinder binder)
 {
     return(default(bool));
 }
Exemplo n.º 12
0
 public virtual void DeleteMember(DeleteMemberBinder binder){ throw Fallback(); }
Exemplo n.º 13
0
 public override bool TryDeleteMember(DeleteMemberBinder binder)
 {
     DeletePropertyByName(binder.Name);
     return true;
 }
 public override bool TryDeleteMember(DeleteMemberBinder binder)
 {
     return Members.Remove(binder.Name);
 }
Exemplo n.º 15
0
 public virtual DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 16
0
 public override Boolean TryDeleteMember(DeleteMemberBinder binder)
 {
     throw new NotImplementedException("JsStore.TryDeleteMember");
 }
Exemplo n.º 17
0
 /// <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);
 }
Exemplo n.º 18
0
 /// <summary>
 /// Override on DynamicObject
 /// </summary>
 /// <param name="binder"></param>
 /// <returns></returns>
 public override bool TryDeleteMember(DeleteMemberBinder binder)
 {
     return true;
 }
Exemplo n.º 19
0
 public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
 {
     return Restrict(StorageMetaObject.BindDeleteMember(binder));
 }
Exemplo n.º 20
0
 /// <summary>
 ///     Performs the binding of the dynamic delete member operation.
 /// </summary>
 /// <param name="binder">
 ///     An instance of the <see cref="T:System.Dynamic.DeleteMemberBinder" /> that represents the details of the dynamic operation.
 /// </param>
 /// <returns>
 ///     The new <see cref="T:System.Dynamic.DynamicMetaObject" /> representing the result of the binding.
 /// </returns>
 public override DynamicMetaObject BindDeleteMember( DeleteMemberBinder binder )
 {
     return ApplyBinding( meta => meta.BindDeleteMember( binder ), binder.FallbackDeleteMember );
 }
Exemplo n.º 21
0
 public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
 {
     return new DynamicMetaObject(
         Expression.Condition(
             Expression.Invoke(
                 Expression.Constant(_deleteMember),
                 Expression,
                 Expression.Constant(binder.Name)
             ),
             Expression.Default(binder.ReturnType),
             binder.FallbackDeleteMember(this).Expression
         ),
         GetRestrictions()
     );
 }
Exemplo n.º 22
0
 public override bool TryDeleteMember( DeleteMemberBinder binder )
 {
     if(!ReferenceEquals(Prototype, null))
     {
         if(Prototype.TryDeleteMember(binder))
         {
             return true;
         }
     }
     if ( TryDeleteMemberMissing == null )
     {
         return true;
     }
     return TryDeleteMemberMissing( binder );
 }
 public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
 {
     Fallback fallback = null;
     if (!this.IsOverridden("TryDeleteMember"))
     {
         return base.BindDeleteMember(binder);
     }
     if (fallback == null)
     {
         fallback = e => binder.FallbackDeleteMember(this, e);
     }
     return this.CallMethodNoResult("TryDeleteMember", binder, NoArgs, fallback);
 }
Exemplo n.º 24
0
 public virtual bool TryDeleteMember(DeleteMemberBinder binder)
 {
     throw new NotImplementedException();
 }
 public virtual new bool TryDeleteMember(DeleteMemberBinder binder)
 {
   return default(bool);
 }
Exemplo n.º 26
0
 public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
 {
     return scriptItem.PostProcessBindResult(metaDynamic.BindDeleteMember(binder));
 }
Exemplo n.º 27
0
            public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder) {
                if (IsOverridden("TryDeleteMember")) {
                    return CallMethodNoResult("TryDeleteMember", binder, NoArgs, (e) => binder.FallbackDeleteMember(this, e));
                }

                return base.BindDeleteMember(binder);
            }
 public override bool TryDeleteMember(DeleteMemberBinder binder)
 {
     Dictionary.Remove(binder.Name);
     return true;
 }
Exemplo n.º 29
0
 public override bool TryDeleteMember(DeleteMemberBinder binder)
 {
     return base.TryDeleteMember(binder);
 }
Exemplo n.º 30
0
        /// <summary>
        /// Provides the implementation for operations that delete an object member. This method is not intended for use in C# or
        /// Visual Basic.
        /// </summary>
        /// <returns>
        /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language
        /// determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
        /// </returns>
        /// <param name="binder">Provides information about the deletion.</param>
        public override bool TryDeleteMember(DeleteMemberBinder binder)
        {
            if (binder == null)
            {
                throw new ArgumentNullException("binder");
            }

            if (m_dictionary.ContainsKey(binder.Name))
            {
                m_dictionary.Remove(binder.Name);
                return true;
            }

            return base.TryDeleteMember(binder);
        }
Exemplo n.º 31
0
 /// <summary>
 /// Provides the implementation for operations that delete an object member.
 /// </summary>
 /// <returns>true if the operation is successful; otherwise, false.</returns>
 /// <param name="binder">Provides information about the deletion.</param>
 public override bool TryDeleteMember(DeleteMemberBinder binder)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 32
0
 public override Boolean TryDeleteMember(DeleteMemberBinder binder)
 {
     throw new NotImplementedException(String.Format("TryDeleteMember name='{0}'", binder.Name));
 }
Exemplo n.º 33
0
 /// <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)
 {
     ArgumentNullException.ThrowIfNull(binder);
     return(binder.FallbackDeleteMember(this));
 }
Exemplo n.º 34
0
 /// <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) => false;
Exemplo n.º 35
0
 public override bool TryDeleteMember( DeleteMemberBinder binder )
 {
     if ( TryDeleteMemberMissing == null )
     {
         return true;
     }
     return TryDeleteMemberMissing( binder );
 }
Exemplo n.º 36
0
		public override bool TryDeleteMember(DeleteMemberBinder binder)
		{
			//--- Debbuger Break --- //
			if(System.Diagnostics.Debugger.IsAttached)
				System.Diagnostics.Debugger.Break();
			//--- Debbuger Break --- //

			return base.TryDeleteMember(binder);
		}
Exemplo n.º 37
0
 public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 38
0
 /// <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);
 }
Exemplo n.º 39
0
 public override bool TryDeleteMember(DeleteMemberBinder binder)
 {
     MessageBox.Show("Here");
     return base.TryDeleteMember(binder);
 }
Exemplo n.º 40
0
 /// <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;
 }
Exemplo n.º 41
0
            public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder) {
                ContractUtils.RequiresNotNull(binder, "binder");

                string methodName = binder.IgnoreCase ? "ExpandoTryDeleteValueIgnoreCase" : "ExpandoTryDeleteValue";
                int index = Value.Class.GetValueIndex(binder.Name, binder.IgnoreCase, Value);

                Expression tryDelete = Expression.Call(
                    typeof(RuntimeOps).GetMethod(methodName),
                    GetLimitedSelf(),
                    Expression.Constant(Value.Class),
                    Expression.Constant(index)
                );
                DynamicMetaObject fallback = binder.FallbackDeleteMember(this);

                DynamicMetaObject target = new DynamicMetaObject(
                    Expression.Condition(
                        Expression.IsFalse(tryDelete),
                        Helpers.Convert(fallback.Expression, typeof(object)), //if fail to delete, fall back
                        Helpers.Convert(Expression.Constant(true), typeof(object))
                    ),
                    fallback.Restrictions
                );

                return AddDynamicTestAndDefer(
                    binder,
                    new DynamicMetaObject[] { this },
                    Value.Class,
                    null,
                    target
                );
            }
Exemplo n.º 42
0
 /// <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));
 }
    public virtual new System.Dynamic.DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
    {
      Contract.Requires(binder != null);

      return default(System.Dynamic.DynamicMetaObject);
    }
Exemplo n.º 44
0
        public sealed override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
        {
            var fallback = ((Func<Expression>)(() =>
            {
                try { return base.BindDeleteMember(binder).Expression; }
                catch (Exception ex) { return Expression.Throw(Expression.Constant(ex)); }
            }))();

            var dispatchResult = Expression.Parameter(typeof(DispatchResult), "dispatchResult");
            var shim = Expression.Block(dispatchResult.MkArray(),
                // 1. var dispatchResult = DispatchDeleteMember(binder, `expression`);
                Expression.Assign(dispatchResult, Expression.Call(
                    Expression.Constant(this),
                    typeof(SimpleMetaObject).GetMethod("DispatchDeleteMember", BF.PrivateInstance),
                    Expression.Constant(binder),
                    Expression)),
                // 2. if (!dispatchResult.Success) `fallback`;
                Expression.IfThen(
                    Expression.Not(Expression.Property(dispatchResult, "Success")),
                    fallback));
            return new DynamicMetaObject(shim, BindingRestrictions.GetTypeRestriction(Expression, LimitType));
        }
Exemplo n.º 45
0
        public virtual new System.Dynamic.DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder)
        {
            Contract.Requires(binder != null);

            return(default(System.Dynamic.DynamicMetaObject));
        }