public void Post(string submissionUrl, BacktraceJObject jObject, Action <long, bool, string> onComplete)
 {
     NumberOfRequests++;
     Called = true;
     OnInvoke?.Invoke(submissionUrl, jObject);
     onComplete?.Invoke(StatusCode, IsHttpError, Response);
 }
 protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
 {
     if (OnInvoke != null)
     {
         await OnInvoke.Invoke(request);
     }
     return(Response);
 }
Beispiel #3
0
 public void Invoke(OnInvoke Method, object arg)
 {
     if (this.InvokeQueue == null)
     {
         this.InvokeQueue = new Queue();
     }
     Queue.Synchronized(this.InvokeQueue).Enqueue((object)new Invokable(Method, arg));
 }
        public MFAsyncCallback(OnInvoke onInvokeMethod)
        {
            if (onInvokeMethod == null)
            {
                throw new ArgumentNullException("onInvokeMethod");
            }

            m_onInvokeMethod = onInvokeMethod;
        }
 public void Invoke()
 {
     if (OnInvoke != null)
     {
         OnInvoke.Invoke(this, new GlobalEventEventArgs()
         {
             globalEvent = this
         });
     }
 }
        /// <summary>
        /// Invokes the given command.
        /// </summary>
        /// <param name="command">The command to invoke.</param>
        /// <returns>The return value, if any, of the invoked command.</returns>
        public object InvokeCommand(string command)
        {
            object commandResult = null;

            if (!string.IsNullOrWhiteSpace(command))
            {
                string commandLog = $"> {command}";
                if (_theme)
                {
                    commandLog = commandLog.ColorText(_theme.CommandLogColor);
                }
                LogToConsole(commandLog);

                string logTrace = string.Empty;
                try
                {
                    commandResult = QuantumConsoleProcessor.InvokeCommand(command);

                    switch (commandResult)
                    {
                    case Task task: _currentTasks.Add(task); break;

                    case IEnumerator <ICommandAction> action: StartAction(action); break;

                    case IEnumerable <ICommandAction> action: StartAction(action.GetEnumerator()); break;

                    default: logTrace = Serialize(commandResult); break;
                    }
                }
                catch (System.Reflection.TargetInvocationException e) { logTrace = GetInvocationErrorMessage(e.InnerException); }
                catch (Exception e) { logTrace = GetErrorMessage(e); }

                LogToConsole(logTrace);
                OnInvoke?.Invoke(command);

                if (_autoScroll == AutoScrollOptions.OnInvoke)
                {
                    ScrollConsoleToLatest();
                }
                if (_closeOnSubmit)
                {
                    Deactivate();
                }
            }
            else
            {
                OverrideConsoleInput(string.Empty);
            }

            return(commandResult);
        }
Beispiel #7
0
        /// <summary>
        /// Invokes the given command.
        /// </summary>
        /// <param name="command">The command to invoke.</param>
        /// <returns>The return value, if any, of the invoked command.</returns>
        public object InvokeCommand(string command)
        {
            object commandResult = null;

            if (!string.IsNullOrWhiteSpace(command))
            {
                string commandLog = $"> {command}";
                if (_theme)
                {
                    commandLog = commandLog.ColorText(_theme.CommandLogColor);
                }
                LogToConsole(commandLog);

                string logTrace = string.Empty;
                try
                {
                    commandResult = QuantumConsoleProcessor.InvokeCommand(command);

                    if (commandResult is Task task)
                    {
                        _currentTasks.Add(task);
                    }
                    else
                    {
                        logTrace = _serializer.SerializeFormatted(commandResult, _theme);
                    }
                }
                catch (System.Reflection.TargetInvocationException e) { logTrace = GetInvocationErrorMessage(e.InnerException); }
                catch (Exception e) { logTrace = GetErrorMessage(e); }

                LogToConsole(logTrace);
                OnInvoke?.Invoke(command);

                if (_autoScroll == AutoScrollOptions.OnInvoke)
                {
                    ScrollConsoleToLatest();
                }
                if (_closeOnSubmit)
                {
                    Deactivate();
                }
            }
            else
            {
                OverrideConsoleInput(string.Empty);
            }

            return(commandResult);
        }
 public override void Invoke(ICommandManager commandManager)
 => OnInvoke?.Invoke(commandManager);
Beispiel #9
0
 public Invokable(OnInvoke Method, object arg)
 {
     this.Method    = Method;
     this.Parameter = arg;
 }
 public void Invoke()
 {
     OnInvoke.Invoke();
 }
Beispiel #11
0
 public object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
 {
     return(OnInvoke?.Invoke(args));
 }
Beispiel #12
0
 /// <summary>
 /// Invokes the <see cref="OnInvoke"/> method.
 /// </summary>
 /// <param name="args">The arguments to pass to the callback.</param>
 /// <returns>The return value of the callback.</returns>
 public LuaResult Invoke(params object[] args)
 {
     return((LuaResult)OnInvoke.FastDynamicInvoke(args));
 }