/// <summary>
        /// Executes a <see cref="WuRemoteCall"/> on the <see cref="IWuEndpoint"/> for this view model.
        /// </summary>
        /// <param name="call">Call to execute.</param>
        /// <param name="param">Call parameter.</param>
        protected async Task <WuRemoteCallResult> ExecuteRemoteCallAsync(WuRemoteCall call, object param)
        {
            if (call == null)
            {
                throw new ArgumentNullException(nameof(call));
            }

            IWuEndpoint endpoint;

            if (TryGetEndpoint(out endpoint))
            {
                try
                {
                    Log.Debug($"Execute remote call async: {call.GetType().Name}, Param: {param?.ToString()}");
                    return(await call.CallAsync(endpoint, param));
                }
                catch (Exception e)
                {
                    Log.Error($"Execute remote call async failed: {call.GetType().Name}, Param: {param?.ToString()}", e);
                    return(new WuRemoteCallResult(endpoint, call, false, e, null));
                }
            }
            else
            {
                return(new WuRemoteCallResult(endpoint, call, false, null, "The remote service is not longer available."));
            }
        }
コード例 #2
0
        public void Execute(object param)
        {
            var endpoints = WuEndpointSelector();

            if (endpoints != null)
            {
                foreach (var e in endpoints)
                {
                    RemoteCall.CallAsync(e, param);
                }
            }
        }