private async Task <TResult> GetWithAsync <TResult, TServerResponse>(Func <TServerResponse, TResult> converter, Func <Mage_Api_Model_Server_Wsi_HandlerPortTypeClient, string, Task <TServerResponse> > action, int abortAfter, bool suppressException = false, [CallerMemberName] string callerName = null) where TServerResponse : new() { try { var res = new TServerResponse(); var privateClient = this._clientFactory.GetClient(); await ActionPolicies.GetAsync.Do(async() => { privateClient = this._clientFactory.RefreshClient(privateClient); var sessionId = await this.GetSessionId().ConfigureAwait(false); var temp = await ClientBaseActionRunner.RunWithAbortAsync( abortAfter, async() => res = await action(privateClient, sessionId.SessionId).ConfigureAwait(false), privateClient).ConfigureAwait(false); if (temp.Item2) { throw new TaskCanceledException(); } }).ConfigureAwait(false); return(converter(res)); } catch (Exception exc) { if (suppressException) { return(default(TResult)); } throw new MagentoSoapException($"An error occured during{callerName}->{nameof( this.GetWithAsync )}", exc); } }
private async Task <TResult> GetWithUnsafeAsync <TResult, TServerResponse>(Func <TServerResponse, TResult> converter, Func <Mage_Api_Model_Server_Wsi_HandlerPortTypeClient, string, Task <TServerResponse> > action, int abortAfter) where TServerResponse : new() { var res = new TServerResponse(); var privateClient = this._clientFactory.GetClient(); await ActionPolicies.GetAsync.Do(async() => { privateClient = this._clientFactory.RefreshClient(privateClient); var sessionId = await this.GetSessionId().ConfigureAwait(false); var temp = await ClientBaseActionRunner.RunWithAbortAsync( abortAfter, async() => res = await action(privateClient, sessionId.SessionId).ConfigureAwait(false), privateClient).ConfigureAwait(false); if (temp.Item2) { throw new TaskCanceledException(); } }).ConfigureAwait(false); return(converter(res)); }