예제 #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 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);
        }