From caad12a8153bc0c1f949d98bc75b690c22d779da Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Fri, 27 Aug 2021 16:42:10 +0800 Subject: [PATCH] Generate part class --- .../Abp/Cli/Commands/GenerateProxyCommand.cs | 17 ++- .../Volo/Abp/Cli/Commands/ProxyCommandBase.cs | 37 +++--- .../Abp/Cli/Commands/RemoveProxyCommand.cs | 2 +- .../Angular/AngularServiceProxyGenerator.cs | 1 - .../CSharp/CSharpServiceProxyGenerator.cs | 113 +++++++++++++----- .../Abp/Cli/ServiceProxy/GenerateProxyArgs.cs | 4 + .../JavaScriptServiceProxyGenerator.cs | 29 +++-- .../Volo/Abp/Http/Client/ClientProxyBase.cs | 16 +-- .../DynamicHttpProxyInterceptor.cs | 2 +- 9 files changed, 157 insertions(+), 64 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs index ec61d86cc1..85c0a8861c 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs @@ -1,3 +1,4 @@ +using System.Text; using Microsoft.Extensions.Options; using Volo.Abp.Cli.ServiceProxy; using Volo.Abp.DependencyInjection; @@ -17,9 +18,23 @@ namespace Volo.Abp.Cli.Commands { } + public override string GetUsageInfo() + { + var sb = new StringBuilder(base.GetUsageInfo()); + + sb.AppendLine(""); + sb.AppendLine("Examples:"); + sb.AppendLine(""); + sb.AppendLine(" abp new generate-proxy -t ng"); + sb.AppendLine(" abp new Acme.BookStore -t js -m identity -o Pages/Identity/client-proxies.js"); + sb.AppendLine(" abp new Acme.BookStore -t csharp --folder MyProxies/InnerFolder"); + + return sb.ToString(); + } + public override string GetShortDescription() { - return "Generates Angular service proxies and DTOs to consume HTTP APIs."; + return "Generates client service proxies and DTOs to consume HTTP APIs."; } } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs index 4765f8540e..d70d396504 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs @@ -66,11 +66,12 @@ namespace Volo.Abp.Cli.Commands var apiName = commandLineArgs.Options.GetOrNull(Options.ApiName.Short, Options.ApiName.Long); var source = commandLineArgs.Options.GetOrNull(Options.Source.Short, Options.Source.Long); var workDirectory = commandLineArgs.Options.GetOrNull(Options.WorkDirectory.Short, Options.WorkDirectory.Long) ?? Directory.GetCurrentDirectory(); + var folder = commandLineArgs.Options.GetOrNull(Options.Folder.Long); - return new GenerateProxyArgs(CommandName, workDirectory, module.ToLower(), url, output, target, apiName, source, commandLineArgs.Options); + return new GenerateProxyArgs(CommandName, workDirectory, module.ToLower(), url, output, target, apiName, source, folder, commandLineArgs.Options); } - public string GetUsageInfo() + public virtual string GetUsageInfo() { var sb = new StringBuilder(); @@ -81,11 +82,15 @@ namespace Volo.Abp.Cli.Commands sb.AppendLine(""); sb.AppendLine("Options:"); sb.AppendLine(""); - sb.AppendLine("-m|--module (default: 'app') The name of the backend module you wish to generate proxies for."); - sb.AppendLine("-a|--api-name (default: 'default') The name of the API endpoint defined in the /src/environments/environment.ts."); - sb.AppendLine("-s|--source (default: 'defaultProject') Angular project name to resolve the root namespace & API definition URL from."); - sb.AppendLine("-o|--output (default: 'defaultProject') Angular project name to place generated code in."); - sb.AppendLine("-p|--prompt Asks the options from the command line prompt (for the missing options)"); + sb.AppendLine("-m|--module (default: 'app') The name of the backend module you wish to generate proxies for."); + sb.AppendLine("-t|--type The name of generate type (csharp, js, ng)."); + sb.AppendLine("-wd|--working-directory Execution directory."); + sb.AppendLine("-a|--api-name (default: 'default') The name of the API endpoint defined in the /src/environments/environment.ts."); + sb.AppendLine("-s|--source (default: 'defaultProject') Angular project name to resolve the root namespace & API definition URL from."); + sb.AppendLine("-o|--output JavaScript file path or folder to place generated code in."); + sb.AppendLine("-p|--prompt Asks the options from the command line prompt (for the missing options)"); + sb.AppendLine("--target (default: 'defaultProject') Angular project name to place generated code in."); + sb.AppendLine("--folder (default: 'ClientProxies') Folder name to place generated CSharp code in."); sb.AppendLine(""); sb.AppendLine("See the documentation for more info: https://docs.abp.io/en/abp/latest/CLI"); @@ -102,6 +107,12 @@ namespace Volo.Abp.Cli.Commands public const string Long = "module"; } + public static class GenerateType + { + public const string Short = "t"; + public const string Long = "type"; + } + public static class ApiName { public const string Short = "a"; @@ -113,13 +124,6 @@ namespace Volo.Abp.Cli.Commands public const string Short = "s"; public const string Long = "source"; } - - public static class GenerateType - { - public const string Short = "t"; - public const string Long = "type"; - } - public static class Output { public const string Short = "o"; @@ -137,6 +141,11 @@ namespace Volo.Abp.Cli.Commands public const string Long = "prompt"; } + public static class Folder + { + public const string Long = "folder"; + } + public static class Url { public const string Long = "url"; diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/RemoveProxyCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/RemoveProxyCommand.cs index dc193e0773..9faaff3ea0 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/RemoveProxyCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/RemoveProxyCommand.cs @@ -19,7 +19,7 @@ namespace Volo.Abp.Cli.Commands public override string GetShortDescription() { - return "Remove Angular service proxies and DTOs to consume HTTP APIs."; + return "Remove client service proxies and DTOs to consume HTTP APIs."; } } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/Angular/AngularServiceProxyGenerator.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/Angular/AngularServiceProxyGenerator.cs index 8a4e2c3da7..dc70b55524 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/Angular/AngularServiceProxyGenerator.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/Angular/AngularServiceProxyGenerator.cs @@ -38,7 +38,6 @@ namespace Volo.Abp.Cli.ServiceProxy.Angular var source = args.Source ?? defaultValue; var target = args.Target ?? defaultValue; - var commandBuilder = new StringBuilder("npx ng g @abp/ng.schematics:" + schematicsCommandName); if (module != null) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/CSharp/CSharpServiceProxyGenerator.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/CSharp/CSharpServiceProxyGenerator.cs index 78eb25c511..66f847d73b 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/CSharp/CSharpServiceProxyGenerator.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/CSharp/CSharpServiceProxyGenerator.cs @@ -6,6 +6,7 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Xml; +using Volo.Abp.Cli.Commands; using Volo.Abp.Cli.Http; using Volo.Abp.DependencyInjection; using Volo.Abp.Http.Modeling; @@ -17,24 +18,31 @@ namespace Volo.Abp.Cli.ServiceProxy.CSharp public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase, ITransientDependency { public const string Name = "CSHARP"; - public const string UsingPlaceholder = ""; - public const string MethodPlaceholder = ""; - public const string ClassName = ""; - public const string ServiceInterface = ""; - public const string ServicePostfix = "APPSERVICE"; - public const string DefaultNamespace = "ClientProxies"; - public const string Namespace = ""; - - public readonly string ClientProxyTemplate = "" + - $"{Environment.NewLine}" + - $"{Environment.NewLine}namespace " + - $"{Environment.NewLine}{{" + - $"{Environment.NewLine} public class : ClientProxyBase<>, " + - $"{Environment.NewLine} {{" + - $"{Environment.NewLine} " + - $"{Environment.NewLine} }}" + - $"{Environment.NewLine}}}"; + private const string UsingPlaceholder = ""; + private const string MethodPlaceholder = ""; + private const string ClassName = ""; + private const string ServiceInterface = ""; + private const string ServicePostfix = "APPSERVICE"; + private const string DefaultNamespace = "ClientProxies"; + private const string Namespace = ""; + private readonly string _clientProxyTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" + + $"{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"{Environment.NewLine}namespace " + + $"{Environment.NewLine}{{" + + $"{Environment.NewLine} public partial class : ClientProxyBase<>, " + + $"{Environment.NewLine} {{" + + $"{Environment.NewLine} " + + $"{Environment.NewLine} }}" + + $"{Environment.NewLine}}}"; + private readonly string _clientProxyPartialTemplate = "// This file is part of , you can customize it here" + + $"{Environment.NewLine}namespace " + + $"{Environment.NewLine}{{" + + $"{Environment.NewLine} public partial class " + + $"{Environment.NewLine} {{" + + $"{Environment.NewLine} }}" + + $"{Environment.NewLine}}}"; private readonly List _usingNamespaceList = new() { "using System;", @@ -54,6 +62,13 @@ namespace Volo.Abp.Cli.ServiceProxy.CSharp public override async Task GenerateProxyAsync(GenerateProxyArgs args) { var projectFilePath = CheckWorkDirectory(args.WorkDirectory); + + if (args.CommandName == RemoveProxyCommand.Name) + { + RemoveClientProxyFile(args); + return; + } + var projectName = Path.GetFileNameWithoutExtension(projectFilePath); var assemblyFilePath = Path.Combine(args.WorkDirectory, "bin", "Debug", GetTargetFrameworkVersion(projectFilePath), $"{projectName}.dll"); var startupModule = GetStartupModule(assemblyFilePath); @@ -68,34 +83,46 @@ namespace Volo.Abp.Cli.ServiceProxy.CSharp { if (ShouldGenerateProxy(controller.Value)) { - await GenerateClientProxyFile(args, controller.Value, appServiceTypes, startupModule.Namespace); + await GenerateClientProxyFileAsync(args, controller.Value, appServiceTypes, startupModule.Namespace); } } } - protected virtual async Task GenerateClientProxyFile(GenerateProxyArgs args, ControllerApiDescriptionModel controllerApiDescription, List appServiceTypes, string rootNamespace) + private void RemoveClientProxyFile(GenerateProxyArgs args) { - var appServiceType = appServiceTypes.FirstOrDefault(x => x.FullName == controllerApiDescription.Interfaces.Last().Type); + var folder = args.Folder.IsNullOrWhiteSpace()? DefaultNamespace : args.Folder; + var folderPath = Path.Combine(args.WorkDirectory, folder); - if (appServiceType == null) + if (Directory.Exists(folderPath)) { - return; + Directory.Delete(folderPath, true); } + } - var folder = DefaultNamespace; - if (args.ExtraProperties.ContainsKey("--folder")) + private async Task GenerateClientProxyFileAsync( + GenerateProxyArgs args, + ControllerApiDescriptionModel controllerApiDescription, + List appServiceTypes, + string rootNamespace) + { + var appServiceType = appServiceTypes.FirstOrDefault(x => x.FullName == controllerApiDescription.Interfaces.Last().Type); + + if (appServiceType == null) { - folder = args.ExtraProperties["--folder"]; + return; } + var folder = args.Folder.IsNullOrWhiteSpace()? DefaultNamespace : args.Folder; var usingNamespaceList = new List(_usingNamespaceList); var clientProxyName = $"{controllerApiDescription.ControllerName}ClientProxy"; - var clientProxyBuilder = new StringBuilder(ClientProxyTemplate); + var clientProxyBuilder = new StringBuilder(_clientProxyTemplate); + var fileNamespace = $"{rootNamespace}.{folder.Replace('/', '.')}"; + usingNamespaceList.Add($"using {appServiceType.Namespace};"); + clientProxyBuilder.Replace(ClassName, clientProxyName); - clientProxyBuilder.Replace(Namespace, $"{rootNamespace}.{folder.Replace('/','.')}"); + clientProxyBuilder.Replace(Namespace, fileNamespace); clientProxyBuilder.Replace(ServiceInterface, appServiceType.Name); - usingNamespaceList.Add($"using {appServiceType.Namespace};"); var methods = appServiceType.GetInterfaces().SelectMany(x => x.GetMethods()).ToList(); methods.AddRange(appServiceType.GetMethods()); @@ -125,9 +152,28 @@ namespace Volo.Abp.Cli.ServiceProxy.CSharp { await writer.WriteAsync(clientProxyBuilder.ToString()); } + + await GenerateClientProxyPartialFileAsync(clientProxyName, fileNamespace, filePath); + } + + private async Task GenerateClientProxyPartialFileAsync(string clientProxyName, string fileNamespace, string filePath) + { + var clientProxyBuilder = new StringBuilder(_clientProxyPartialTemplate); + clientProxyBuilder.Replace(ClassName, clientProxyName); + clientProxyBuilder.Replace(Namespace, fileNamespace); + + filePath = filePath.Replace(".cs", ".partial.cs"); + using (var writer = new StreamWriter(filePath)) + { + await writer.WriteAsync(clientProxyBuilder.ToString()); + } } - protected virtual void GenerateMethod(ActionApiDescriptionModel actionApiDescription, MethodInfo method, StringBuilder clientProxyBuilder, List usingNamespaceList) + private void GenerateMethod( + ActionApiDescriptionModel actionApiDescription, + MethodInfo method, + StringBuilder clientProxyBuilder, + List usingNamespaceList) { var methodBuilder = new StringBuilder(); @@ -162,7 +208,12 @@ namespace Volo.Abp.Cli.ServiceProxy.CSharp methodBuilder.AppendLine(" }"); } - private void GenerateAsynchronousMethod(ActionApiDescriptionModel actionApiDescription, MethodInfo method, string returnTypeName, StringBuilder methodBuilder, List usingNamespaceList) + private void GenerateAsynchronousMethod( + ActionApiDescriptionModel actionApiDescription, + MethodInfo method, + string returnTypeName, + StringBuilder methodBuilder, + List usingNamespaceList) { methodBuilder.AppendLine($"public async {returnTypeName} {method.Name}()"); @@ -202,7 +253,7 @@ namespace Volo.Abp.Cli.ServiceProxy.CSharp methodBuilder.AppendLine(" }"); } - protected virtual bool ShouldGenerateProxy(ControllerApiDescriptionModel controllerApiDescription) + private bool ShouldGenerateProxy(ControllerApiDescriptionModel controllerApiDescription) { if (!controllerApiDescription.Interfaces.Any()) { diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/GenerateProxyArgs.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/GenerateProxyArgs.cs index 10a89e4be7..d20cd26192 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/GenerateProxyArgs.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/GenerateProxyArgs.cs @@ -23,6 +23,8 @@ namespace Volo.Abp.Cli.ServiceProxy public string Source { get; } + public string Folder { get; } + [NotNull] public Dictionary ExtraProperties { get; set; } @@ -35,6 +37,7 @@ namespace Volo.Abp.Cli.ServiceProxy string target, string apiName, string source, + string folder, Dictionary extraProperties = null) { CommandName = Check.NotNullOrWhiteSpace(commandName, nameof(commandName)); @@ -45,6 +48,7 @@ namespace Volo.Abp.Cli.ServiceProxy Target = target; ApiName = apiName; Source = source; + Folder = folder; ExtraProperties = extraProperties ?? new Dictionary(); } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/JavaScript/JavaScriptServiceProxyGenerator.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/JavaScript/JavaScriptServiceProxyGenerator.cs index e97ba8540b..9d027e7dc5 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/JavaScript/JavaScriptServiceProxyGenerator.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxy/JavaScript/JavaScriptServiceProxyGenerator.cs @@ -2,6 +2,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using Volo.Abp.Cli.Commands; using Volo.Abp.Cli.Http; using Volo.Abp.DependencyInjection; using Volo.Abp.Http.ProxyScripting.Generators.JQuery; @@ -12,8 +13,8 @@ namespace Volo.Abp.Cli.ServiceProxy.JavaScript public class JavaScriptServiceProxyGenerator : ServiceProxyGeneratorBase, ITransientDependency { public const string Name = "JS"; - public const string EventTriggerScript = "abp.event.trigger('abp.serviceProxyScriptInitialized');"; - public const string DefaultOutput = "wwwroot/client-proxies"; + private const string EventTriggerScript = "abp.event.trigger('abp.serviceProxyScriptInitialized');"; + private const string DefaultOutput = "wwwroot/client-proxies"; private readonly JQueryProxyScriptGenerator _jQueryProxyScriptGenerator; @@ -30,15 +31,21 @@ namespace Volo.Abp.Cli.ServiceProxy.JavaScript { CheckWorkDirectory(args.WorkDirectory); - var applicationApiDescriptionModel = await GetApplicationApiDescriptionModelAsync(args); - var script = RemoveInitializedEventTrigger(_jQueryProxyScriptGenerator.CreateScript(applicationApiDescriptionModel)); - - var output = $"{args.WorkDirectory}/{DefaultOutput}/{args.Module}-proxy.js"; + var output = Path.Combine(args.WorkDirectory, DefaultOutput, $"{args.Module}-proxy.js"); if (!args.Output.IsNullOrWhiteSpace()) { - output = !args.Output.EndsWith(".js") ? $"{Path.GetDirectoryName(args.Output)}/{args.Module}-proxy.js" : args.Output; + output = args.Output.EndsWith(".js") ? Path.Combine(args.WorkDirectory, args.Output) : Path.Combine(args.WorkDirectory, Path.GetDirectoryName(args.Output), $"{args.Module}-proxy.js"); } + if (args.CommandName == RemoveProxyCommand.Name) + { + RemoveProxy(output); + return; + } + + var applicationApiDescriptionModel = await GetApplicationApiDescriptionModelAsync(args); + var script = RemoveInitializedEventTrigger(_jQueryProxyScriptGenerator.CreateScript(applicationApiDescriptionModel)); + Directory.CreateDirectory(Path.GetDirectoryName(output)); using (var writer = new StreamWriter(output)) @@ -47,6 +54,14 @@ namespace Volo.Abp.Cli.ServiceProxy.JavaScript } } + private void RemoveProxy(string filePath) + { + if (File.Exists(filePath)) + { + File.Delete(filePath); + } + } + private static void CheckWorkDirectory(string directory) { if (!Directory.Exists(directory)) diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxyBase.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxyBase.cs index bed5bcb268..a1a5b2e436 100644 --- a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxyBase.cs +++ b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/ClientProxyBase.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.Http.Modeling; @@ -6,7 +7,7 @@ using Volo.Abp.Json; namespace Volo.Abp.Http.Client { - public class ClientProxyBase + public class ClientProxyBase : ITransientDependency { public IAbpLazyServiceProvider LazyServiceProvider { get; set; } @@ -15,23 +16,22 @@ namespace Volo.Abp.Http.Client protected virtual async Task MakeRequestAsync(ActionApiDescriptionModel action, params object[] arguments) { - await HttpProxyExecuter.MakeRequestAsync(new HttpProxyExecuterContext(action, BuildArguments(action.Name, arguments), typeof(TService))); + await HttpProxyExecuter.MakeRequestAsync(new HttpProxyExecuterContext(action, BuildArguments(action, arguments), typeof(TService))); } protected virtual async Task MakeRequestAsync(ActionApiDescriptionModel action, params object[] arguments) { - return await HttpProxyExecuter.MakeRequestAndGetResultAsync(new HttpProxyExecuterContext(action, BuildArguments(action.Name, arguments), typeof(TService))); + return await HttpProxyExecuter.MakeRequestAndGetResultAsync(new HttpProxyExecuterContext(action, BuildArguments(action, arguments), typeof(TService))); } - protected virtual Dictionary BuildArguments(string methodName, object[] arguments) + protected virtual Dictionary BuildArguments(ActionApiDescriptionModel action, object[] arguments) { - var method = typeof(TService).GetMethod(methodName); + var parameters = action.Parameters.GroupBy(x => x.NameOnMethod).Select(x => x.Key).ToList(); var dict = new Dictionary(); - var methodParameters = method.GetParameters(); - for (var i = 0; i < methodParameters.Length; i++) + for (var i = 0; i < parameters.Count; i++) { - dict[methodParameters[i].Name] = arguments[i]; + dict[parameters[i]] = arguments[i]; } return dict; diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs index cf138a7b3c..e2b6269e12 100644 --- a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs +++ b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs @@ -64,7 +64,7 @@ namespace Volo.Abp.Http.Client.DynamicProxying { var result = (Task)MakeRequestAndGetResultAsyncMethod .MakeGenericMethod(invocation.Method.ReturnType.GenericTypeArguments[0]) - .Invoke(this, new object[] { context }); + .Invoke(HttpProxyExecuter, new object[] { context }); invocation.ReturnValue = await GetResultAsync( result,