Exemplo n.º 1
0
        // Convert this object into a string.
        public override String ToString()
        {
            // Find the "toString" method on the object or its prototype.
            JSObject       temp = this;
            ScriptFunction toStr;

            do
            {
                toStr = (temp.Get("toString") as ScriptFunction);
                if (toStr != null)
                {
                    // Invoke the "toString" method.
                    return((toStr.Invoke(this)).ToString());
                }
                temp = (temp.GetParent() as JSObject);
            }while(temp != null);
            return(String.Empty);
        }
Exemplo n.º 2
0
        internal override Object Invoke(Object obj, Object thisob, BindingFlags options, Binder binder, Object[] parameters, CultureInfo culture)
        {
            bool   construct = (options & BindingFlags.CreateInstance) != 0;
            bool   brackets  = (options & BindingFlags.GetProperty) != 0 && (options & BindingFlags.InvokeMethod) == 0;
            Object f         = this.func;

            if (f == null)
            {
                f = this.field.GetValue(this.obj);
            }
            FunctionObject func = f as FunctionObject;
            JSObject       jsOb = obj as JSObject;

            if (jsOb != null && func != null && func.isMethod && (func.attributes & MethodAttributes.Virtual) != 0 &&
                jsOb.GetParent() != func.enclosing_scope && ((ClassScope)func.enclosing_scope).HasInstance(jsOb))
            {
                LateBinding lb = new LateBinding(func.name);
                lb.obj = jsOb;
                return(lb.Call(parameters, construct, brackets, ((ScriptObject)this.obj).engine));
            }
            return(LateBinding.CallValue(f, parameters, construct, brackets, ((ScriptObject)this.obj).engine, thisob, binder, culture, null));
        }
Exemplo n.º 3
0
        internal override object Invoke(object obj, object thisob, BindingFlags options, Binder binder, object[] parameters, CultureInfo culture)
        {
            bool   construct = (options & BindingFlags.CreateInstance) != BindingFlags.Default;
            bool   brackets  = ((options & BindingFlags.GetProperty) != BindingFlags.Default) && ((options & BindingFlags.InvokeMethod) == BindingFlags.Default);
            object func      = this.func;

            if (func == null)
            {
                func = this.field.GetValue(base.obj);
            }
            FunctionObject obj3 = func as FunctionObject;
            JSObject       ob   = obj as JSObject;

            if ((((ob != null) && (obj3 != null)) && (obj3.isMethod && ((obj3.attributes & MethodAttributes.Virtual) != MethodAttributes.PrivateScope))) && ((ob.GetParent() != obj3.enclosing_scope) && ((ClassScope)obj3.enclosing_scope).HasInstance(ob)))
            {
                LateBinding binding = new LateBinding(obj3.name)
                {
                    obj = ob
                };
                return(binding.Call(parameters, construct, brackets, ((ScriptObject)base.obj).engine));
            }
            return(LateBinding.CallValue(func, parameters, construct, brackets, ((ScriptObject)base.obj).engine, thisob, binder, culture, null));
        }