예제 #1
0
        internal async Task <PVOutputArrayResponse <TResponseContentType> > ExecuteArrayRequestAsync <TResponseContentType>(IRequest request, Dictionary <string, object> loggingScope, CancellationToken cancellationToken)
        {
            HttpResponseMessage responseMessage = null;

            try
            {
                using (Logger.BeginScope(loggingScope))
                {
                    using (HttpRequestMessage requestMessage = CreateRequestMessage(request))
                    {
                        responseMessage = await ExecuteRequestAsync(requestMessage, cancellationToken).ConfigureAwait(false);
                    }
                    Stream responseStream = await GetResponseContentStreamAsync(responseMessage).ConfigureAwait(false);

                    var result = new PVOutputArrayResponse <TResponseContentType>();
                    result.ApiRateInformation = GetApiRateInformationfromResponse(responseMessage);

                    if (ResponseIsErrorResponse(responseMessage, responseStream, result))
                    {
                        return(result);
                    }

                    IArrayStringReader <TResponseContentType> reader  = StringFactoryContainer.CreateArrayReader <TResponseContentType>();
                    IEnumerable <TResponseContentType>        content = await reader.ReadArrayAsync(responseStream, cancellationToken).ConfigureAwait(false);

                    result.IsSuccess = true;
                    result.Values    = content;
                    return(result);
                }
            }
            finally
            {
                responseMessage.Dispose();
            }
        }
예제 #2
0
        public void StringFactoryContainer_ForType_CreatesArrayReader()
        {
            IArrayStringReader <ISystemSearchResult> reader = StringFactoryContainer.CreateArrayReader <ISystemSearchResult>();

            Assert.That(reader, Is.TypeOf <LineDelimitedArrayStringReader <ISystemSearchResult> >());
        }