Пример #1
0
        public WuRemoteCallContext(WuRemoteCall call, IWuEndpoint endpoint, Task <WuRemoteCallResult> task)
        {
            if (call == null)
            {
                throw new ArgumentNullException(nameof(call));
            }
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }
            if (task == null)
            {
                throw new ArgumentNullException(nameof(task));
            }
            if (task.Status != TaskStatus.Created)
            {
                throw new InvalidOperationException("Task started before added to call context.");
            }

            _callName     = call.Name;
            _endpointName = endpoint.FQDN;
            Result        = null;

            _call     = call;
            _endpoint = endpoint;

            task.ContinueWith((t) => OnTaskFinished(t));
        }
        public WuRemoteCallResult(IWuEndpoint endpoint, WuRemoteCall call, bool success, Exception failure, string message)
        {
            if (call == null)
            {
                throw new ArgumentNullException(nameof(call));
            }

            _endpoint = endpoint;
            _call     = call;
            _success  = success;
            _failure  = failure;
            _message  = (message == null && failure != null) ? _failure.Message : message;
        }
Пример #3
0
        private void OnTaskFinished(Task <WuRemoteCallResult> task)
        {
            Result          = task.Result;
            _lastTaskStatus = task.Status;

            if (task.Exception != null && task.Result == null)
            {
                Result = new WuRemoteCallResult(_endpoint, _call, false, task.Exception, task.Exception.Message);
            }

            _call     = null;
            _endpoint = null;

            lock (_taskLock)
            {
                _task = null;
            }

            OnPropertyChanged(nameof(Result));
        }
 /// <summary>
 /// Returns a successful call result with the given message.
 /// </summary>
 /// <param name="endpoint">The target endpoint.</param>
 /// <param name="call">The call which was send to the endpoint.</param>
 /// <param name="message">Message for the user.</param>
 public static WuRemoteCallResult SuccessResult(IWuEndpoint endpoint, WuRemoteCall call, string message)
 {
     return(new WuRemoteCallResult(endpoint, call, true, null, message));
 }
 /// <summary>
 /// Returns a successful call result with an empty <see cref="Message"/>.
 /// </summary>
 /// <param name="endpoint">The target endpoint.</param>
 /// <param name="call">The call which was send to the endpoint.</param>
 public static WuRemoteCallResult SuccessResult(IWuEndpoint endpoint, WuRemoteCall call)
 {
     return(SuccessResult(endpoint, call, ""));
 }
 /// <summary>
 /// Returns a unsuccessful call result with a 'service not available' message.
 /// </summary>
 /// <param name="endpoint">The target endpoint.</param>
 /// <param name="call">The call which was send to the endpoint.</param>
 public static WuRemoteCallResult EndpointNotAvailableResult(IWuEndpoint endpoint, WuRemoteCall call)
 {
     return(new WuRemoteCallResult(endpoint, call, false, null, "The remote service is currently not available."));
 }
Пример #7
0
 public void Add(WuRemoteCall call, IWuEndpoint endpoint, Task <WuRemoteCallResult> task)
 => Add(new WuRemoteCallContext(call, endpoint, task));