DeleteMember() публичный статический Метод

public static DeleteMember ( Object obj, String name ) : bool
obj Object
name String
Результат bool
Пример #1
0
        internal override bool DeleteMember(String name)
        {
            FieldInfo field = (FieldInfo)this.NameTable[name];

            if (field != null)
            {
                if (field is JSExpandoField)
                {
                    field.SetValue(this, Missing.Value);
                    this.name_table.Remove(name);
                    this.field_table.Remove(field);
                    return(true);
                }
                else if (field is JSPrototypeField)
                {
                    field.SetValue(this, Missing.Value);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (this.parent != null)
            {
                return(LateBinding.DeleteMember(this.parent, name));
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        internal override bool Delete()
        {
            Object[] actual_arguments = this.args == null ? null : this.args.EvaluateAsArray();
            int      n  = actual_arguments.Length;
            Object   ob = this.func.Evaluate();

            if (ob == null)
            {
                return(true);        //As per the standard, not backwards compatible with JS5
            }
            if (n == 0)
            {
                return(true);
            }
            Type       obType   = ob.GetType();
            MethodInfo deleteOp = obType.GetMethod("op_Delete", BindingFlags.ExactBinding | BindingFlags.Public | BindingFlags.Static,
                                                   null, new Type[] { obType, Typeob.ArrayOfObject }, null);

            if (deleteOp == null || (deleteOp.Attributes & MethodAttributes.SpecialName) == 0 || deleteOp.ReturnType != Typeob.Boolean)
            {
                return(LateBinding.DeleteMember(ob, Convert.ToString(actual_arguments[n - 1])));
            }
            else
            {
                deleteOp = new JSMethodInfo(deleteOp);
                return((bool)deleteOp.Invoke(null, new Object[] { ob, actual_arguments }));
            }
        }
        internal override bool DeleteMember(string name)
        {
            FieldInfo info = (FieldInfo)this.NameTable[name];

            if (info != null)
            {
                if (info is JSExpandoField)
                {
                    info.SetValue(this, Microsoft.JScript.Missing.Value);
                    this.name_table.Remove(name);
                    this.field_table.Remove(info);
                    return(true);
                }
                if (info is JSPrototypeField)
                {
                    info.SetValue(this, Microsoft.JScript.Missing.Value);
                    return(true);
                }
                return(false);
            }
            return((base.parent != null) && LateBinding.DeleteMember(base.parent, name));
        }
Пример #4
0
        internal override bool Delete()
        {
            object[] objArray = (this.args == null) ? null : this.args.EvaluateAsArray();
            int      length   = objArray.Length;
            object   obj2     = this.func.Evaluate();

            if (obj2 == null)
            {
                return(true);
            }
            if (length == 0)
            {
                return(true);
            }
            Type       type   = obj2.GetType();
            MethodInfo method = type.GetMethod("op_Delete", BindingFlags.ExactBinding | BindingFlags.Public | BindingFlags.Static, null, new Type[] { type, Typeob.ArrayOfObject }, null);

            if (((method == null) || ((method.Attributes & MethodAttributes.SpecialName) == MethodAttributes.PrivateScope)) || (method.ReturnType != Typeob.Boolean))
            {
                return(LateBinding.DeleteMember(obj2, Microsoft.JScript.Convert.ToString(objArray[length - 1])));
            }
            method = new JSMethodInfo(method);
            return((bool)method.Invoke(null, new object[] { obj2, objArray }));
        }