コード例 #1
0
 public ScriptRunnerResult Run(JsonOperationContext jsonCtx, DocumentsOperationContext docCtx, string method, object[] args)
 {
     _docsCtx = docCtx;
     _jsonCtx = jsonCtx ?? ThrowArgumentNull();
     Reset();
     if (_args.Length != args.Length)
     {
         _args = new JsValue[args.Length];
     }
     for (var i = 0; i < args.Length; i++)
     {
         _args[i] = TranslateToJs(ScriptEngine, jsonCtx, args[i]);
     }
     try
     {
         var call   = ScriptEngine.GetValue(method).TryCast <ICallable>();
         var result = call.Call(Undefined.Instance, _args);
         return(new ScriptRunnerResult(this, result));
     }
     catch (JavaScriptException e)
     {
         throw CreateFullError(e);
     }
     finally
     {
         _refResolver.ExplodeArgsOn(null, null);
         _docsCtx = null;
         _jsonCtx = null;
     }
 }
コード例 #2
0
            public ScriptRunnerResult Run(DocumentsOperationContext ctx, string method, object[] args)
            {
                _context = ctx;
                Reset();
                if (_args.Length != args.Length)
                {
                    _args = new JsValue[args.Length];
                }
                for (var i = 0; i < args.Length; i++)
                {
                    _args[i] = TranslateToJs(ScriptEngine, ctx, args[i]);
                }
                JsValue result;

                try
                {
                    var call = ScriptEngine.GetValue(method).TryCast <ICallable>();
                    result = call.Call(Undefined.Instance, _args);
                }
                catch (JavaScriptException e)
                {
                    throw CreateFullError(ctx, e);
                }
                finally
                {
                    _refResolver.ExplodeArgsOn(null, null);
                }
                return(new ScriptRunnerResult(this, result));
            }