상속: JSMethod, IWrappedMember
예제 #1
0
        public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
        {
            MethodInfo setter = this.setter;
            JSObject   obj2   = obj as JSObject;

            if ((setter == null) && (obj2 != null))
            {
                setter = obj2.GetMethod("set_" + this.name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                JSWrappedMethod method = setter as JSWrappedMethod;
                if (method != null)
                {
                    setter = method.method;
                }
            }
            if (setter == null)
            {
                setter = this.GetSetMethod(false);
            }
            if (setter != null)
            {
                if ((index == null) || (index.Length == 0))
                {
                    setter.Invoke(obj, invokeAttr, binder, new object[] { value }, culture);
                }
                else
                {
                    int      length = index.Length;
                    object[] target = new object[length + 1];
                    ArrayObject.Copy(index, 0, target, 0, length);
                    target[length] = value;
                    setter.Invoke(obj, invokeAttr, binder, target, culture);
                }
            }
        }
예제 #2
0
        public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
        {
            MethodInfo getter = this.getter;
            JSObject   obj2   = obj as JSObject;

            if ((getter == null) && (obj2 != null))
            {
                getter = obj2.GetMethod("get_" + this.name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                JSWrappedMethod method = getter as JSWrappedMethod;
                if (method != null)
                {
                    getter = method.method;
                }
            }
            if (getter == null)
            {
                getter = this.GetGetMethod(false);
            }
            if (getter != null)
            {
                try
                {
                    return(getter.Invoke(obj, invokeAttr, binder, (index == null) ? new object[0] : index, culture));
                }
                catch (TargetInvocationException exception)
                {
                    throw exception.InnerException;
                }
            }
            return(Microsoft.JScript.Missing.Value);
        }
예제 #3
0
        public override Object GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
        {
            MethodInfo getter = this.getter;
            JSObject   jsOb   = obj as JSObject;

            if (getter == null && jsOb != null)
            {
                getter = jsOb.GetMethod("get_" + this.name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                JSWrappedMethod wrm = getter as JSWrappedMethod;
                if (wrm != null)
                {
                    getter = wrm.method;
                }
            }
            if (getter == null)
            {
                getter = this.GetGetMethod(false);
            }
            if (getter != null)
            {
                return(getter.Invoke(obj, invokeAttr, binder, index == null ? new Object[0] : index, culture));
            }
            else
            {
                return(Missing.Value);
            }
        }
예제 #4
0
 internal override Object Call(Object[] args, Object thisob, Binder binder, CultureInfo culture)
 {
     if (thisob is GlobalScope || thisob == null)
     {
         thisob = this.obj;
     }
     else if ((!this.obj.GetType().IsInstanceOfType(thisob) && !(this.obj is ClassScope)))
     {
         if (this.members.Length == 1)
         {
             JSWrappedMethod wm = this.members[0] as JSWrappedMethod;
             if (wm != null && wm.DeclaringType == Typeob.Object)
             {
                 return(LateBinding.CallOneOfTheMembers(new MemberInfo[] { wm.method }, args, false, thisob, binder, culture, null, this.engine));
             }
         }
         throw new JScriptException(JSError.TypeMismatch);
     }
     return(LateBinding.CallOneOfTheMembers(this.members, args, false, thisob, binder, culture, null, this.engine));
 }
예제 #5
0
        internal override object Call(object[] args, object thisob, Binder binder, CultureInfo culture)
        {
            MethodInfo info = this.members[0] as MethodInfo;

            if (((thisob is GlobalScope) || (thisob == null)) || ((info != null) && ((info.Attributes & MethodAttributes.Static) != MethodAttributes.PrivateScope)))
            {
                thisob = this.obj;
            }
            else if (!this.obj.GetType().IsInstanceOfType(thisob) && !(this.obj is ClassScope))
            {
                if (this.members.Length == 1)
                {
                    JSWrappedMethod method = this.members[0] as JSWrappedMethod;
                    if ((method != null) && (method.DeclaringType == Typeob.Object))
                    {
                        return(LateBinding.CallOneOfTheMembers(new MemberInfo[] { method.method }, args, false, thisob, binder, culture, null, base.engine));
                    }
                }
                throw new JScriptException(JSError.TypeMismatch);
            }
            return(LateBinding.CallOneOfTheMembers(this.members, args, false, thisob, binder, culture, null, base.engine));
        }