예제 #1
0
 public override object Construct(ExecutionContext GLOBAL, JSObjectBase args, ExecutionContext x)
 {
     object[] arglist = null;
     foreach (ConstructorInfo c in mThisType.GetConstructors())
     {
         arglist = JSObject.SatisfyArgumentList(GLOBAL, args, c.GetParameters());
         if (arglist != null)
         {
             return(JSObject.ToJS(GLOBAL, c.Invoke(arglist)));
         }
     }
     throw new TypeError("Wrong argument types for " + mThisType.Name + " constructor");
 }
예제 #2
0
        public override object Call(ExecutionContext GLOBAL, object t, JSObjectBase a, ExecutionContext x)
        {
            Delegate   d = mThisRef as Delegate;
            MethodInfo m = d.Method;

            if (d == null)
            {
                throw new TypeError(Class + " isn't callable");
            }

            object[] arglist = JSObject.SatisfyArgumentList(GLOBAL, a, m.GetParameters());
            if (arglist != null)
            {
                return(JSObject.ToJS(GLOBAL, d.DynamicInvoke(arglist)));
            }
            else
            {
                throw new TypeError("Wrong arguments for method " + m.DeclaringType.Name + "." + m.Name);
            }
        }