Пример #1
0
    protected virtual ClientProxyRequestContext BuildHttpProxyClientProxyContext(string methodName, ClientProxyRequestTypeValue arguments = null)
    {
        if (arguments == null)
        {
            arguments = new ClientProxyRequestTypeValue();
        }

        var methodUniqueName = $"{typeof(TService).FullName}.{methodName}.{string.Join("-", arguments.Values.Select(x => TypeHelper.GetFullNameHandlingNullableAndGenerics(x.Key)))}";
        var action           = ClientProxyApiDescriptionFinder.FindAction(methodUniqueName);

        if (action == null)
        {
            throw new AbpException($"The API description of the {typeof(TService).FullName}.{methodName} method was not found!");
        }

        var actionArguments = action.Parameters.GroupBy(x => x.NameOnMethod).ToList();

        if (action.SupportedVersions.Any())
        {
            //TODO: make names configurable
            actionArguments.RemoveAll(x => x.Key == "api-version" || x.Key == "apiVersion");
        }

        return(new ClientProxyRequestContext(
                   action,
                   actionArguments
                   .Select((x, i) => new KeyValuePair <string, object>(x.Key, arguments.Values[i].Value))
                   .ToDictionary(x => x.Key, x => x.Value),
                   typeof(TService)));
    }
Пример #2
0
 protected virtual async Task <T> RequestAsync <T>(string methodName, ClientProxyRequestTypeValue arguments = null)
 {
     return(await RequestAsync <T>(BuildHttpProxyClientProxyContext(methodName, arguments)));
 }