예제 #1
0
        public async Task <ResponseBase> CallAndPrompt <T, T2>(Func <CallAndPromptArgs <T2>, Task <T> > func, CallAndPromptArgs <T2> state) where T : ResponseBase
        {
            for (var i = 0; i < PromptRetryCount; i++)
            {
                CheckForDisposed();

                try
                {
                    var response = await func.Invoke(state);

                    //Use this to get the response as an array of bytes
                    //var data = string.Join(", ", response.Data.Select(b => b.ToString()));

                    if (response.IsSuccess)
                    {
                        return(response);
                    }

                    if (ErrorPrompt == null)
                    {
                        Helpers.HandleErrorResponse(response);
                    }
                    else
                    {
                        await ErrorPrompt(response.ReturnCode, null, state.MemberName);
                    }
                }
                catch (Exception ex)
                {
                    if (ErrorPrompt == null)
                    {
                        throw;
                    }

                    await ErrorPrompt(null, ex, state.MemberName);
                }
            }

            throw new TooManyPromptsException(PromptRetryCount, state.MemberName);
        }
예제 #2
0
        public async Task <ResponseBase> CallAndPrompt <T, T2>(Func <CallAndPromptArgs <T2>, Task <T> > func, CallAndPromptArgs <T2> state) where T : ResponseBase
        {
            for (var i = 0; i < PromptRetryCount; i++)
            {
                CheckForDisposed();

                try
                {
                    var response = await func.Invoke(state);

                    if (response.IsSuccess)
                    {
                        return(response);
                    }

                    if (ErrorPrompt == null)
                    {
                        HandleErrorResponse(response);
                    }
                    else
                    {
                        await ErrorPrompt(response.ReturnCode, null, state.MemberName);
                    }
                }
                catch (Exception ex)
                {
                    if (ErrorPrompt == null)
                    {
                        throw;
                    }

                    await ErrorPrompt(null, ex, state.MemberName);
                }
            }

            throw new TooManyPromptsException(PromptRetryCount, state.MemberName);
        }