示例#1
0
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            var pname   = binder.Name;
            var jsValue = __GetJsValue(pname);

            if (jsValue.IsObject())
            {
                result = new DynamicJsValueForDotNet(jsValue.AsObject(), this._engine);
            }
            else
            {
                result = DynamicConfig.ConvertJsValueToNetObject(jsValue);
            }

            return(true);
        }
示例#2
0
        public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
            result = null;

            var o = this._jsValue.AsObject();

            if (o is Jint.Native.Array.ArrayInstance)
            {
                var ai = o as Jint.Native.Array.ArrayInstance;
                var v  = ai.Get(indexes[0].ToString());
                var vo = DynamicConfig.ConvertJsValueToNetObject(v);
                result = vo;
            }
            else
            {
            }
            return(true);
        }
示例#3
0
        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            var pname   = binder.Name;
            var jsValue = __GetJsValue(pname);

            result = null;

            if (DynamicConfig.IsFunction(jsValue))
            {
                var f = jsValue.AsObject() as Jint.Native.Function.FunctionInstance;
                jsValue = DynamicConfig.CallFunction(f, args, this._engine);
                if (jsValue.IsObject())
                {
                    result = new DynamicJsValueForDotNet(jsValue.AsObject(), this._engine);
                }
                else
                {
                    result = DynamicConfig.ConvertJsValueToNetObject(jsValue);
                }
                return(true);
            }
            return(false);
        }