예제 #1
0
        private static R ResultsSelector <D, Q, R>(ElasticsearchResponse <R> c, D descriptor, bool allow404)
            where Q : FluentRequestParameters <Q>, new()
            where D : IPathInfo <Q>
            where R : BaseResponse
        {
            if (c.Success || allow404 && c.HttpStatusCode == 404)
            {
                c.Response.IsValid = true;
                return(c.Response);
            }
            var badResponse = CreateInvalidInstance <R>(c);

            return(badResponse);
        }
예제 #2
0
        private static R ResultsSelector <D, Q, R>(
            ElasticsearchResponse <R> c,
            D descriptor
            )
            where Q : FluentRequestParameters <Q>, new()
            where D : IRequest <Q>
            where R : BaseResponse
        {
            var config            = descriptor.RequestConfiguration;
            var statusCodeAllowed = config != null && config.AllowedStatusCodes.HasAny(i => i == c.HttpStatusCode);

            if (c.Success || statusCodeAllowed)
            {
                c.Response.IsValid = true;
                return(c.Response);
            }
            var badResponse = CreateInvalidInstance <R>(c);

            return(badResponse);
        }
예제 #3
0
 private static TResponse ResultsSelector <TResponse>(ElasticsearchResponse <TResponse> c)
     where TResponse : ResponseBase =>
 c.Body ?? CreateInvalidInstance <TResponse>(c);
예제 #4
0
 private ElasticsearchResponse <ExistsResponse> ToExistsResponse(IElasticsearchResponse existsDispatch)
 {
     return(ElasticsearchResponse.CloneFrom <ExistsResponse>(existsDispatch, new ExistsResponse(existsDispatch)));
 }