Exemplo n.º 1
0
    protected virtual async Task <T> RequestAsync <T>(ClientProxyRequestContext requestContext)
    {
        var responseContent = await RequestAsync(requestContext);

        if (typeof(T) == typeof(IRemoteStreamContent) ||
            typeof(T) == typeof(RemoteStreamContent))
        {
            /* returning a class that holds a reference to response
            * content just to be sure that GC does not dispose of
            * it before we finish doing our work with the stream */
            return((T)(object)new RemoteStreamContent(
                       await responseContent.ReadAsStreamAsync(),
                       responseContent.Headers?.ContentDisposition?.FileNameStar ??
                       RemoveQuotes(responseContent.Headers?.ContentDisposition?.FileName).ToString(),
                       responseContent.Headers?.ContentType?.ToString(),
                       responseContent.Headers?.ContentLength));
        }

        var stringContent = await responseContent.ReadAsStringAsync();

        if (typeof(T) == typeof(string))
        {
            return((T)(object)stringContent);
        }

        if (stringContent.IsNullOrWhiteSpace())
        {
            return(default);
Exemplo n.º 2
0
    public override async Task InterceptAsync(IAbpMethodInvocation invocation)
    {
        var context = new ClientProxyRequestContext(
            await GetActionApiDescriptionModel(invocation),
            invocation.ArgumentsDictionary,
            typeof(TService));

        if (invocation.Method.ReturnType.GenericTypeArguments.IsNullOrEmpty())
        {
            await InterceptorClientProxy.CallRequestAsync(context);
        }
        else
        {
            var returnType = invocation.Method.ReturnType.GenericTypeArguments[0];
            var result     = (Task)CallRequestAsyncMethod
                             .MakeGenericMethod(returnType)
                             .Invoke(this, new object[] { context });

            invocation.ReturnValue = await GetResultAsync(result, returnType);
        }
    }
Exemplo n.º 3
0
 protected virtual async Task <T> CallRequestAsync <T>(ClientProxyRequestContext context)
 {
     return(await InterceptorClientProxy.CallRequestAsync <T>(context));
 }
 public virtual async Task <T> CallRequestAsync <T>(ClientProxyRequestContext requestContext)
 {
     return(await base.RequestAsync <T>(requestContext));
 }