From 4f359fb677276f585c466edf44ac7388085ec71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Sep 2017 14:14:29 +0300 Subject: [PATCH] Remove module name while creating http client proxies. --- .../Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs | 2 +- .../AspNetCore/Mvc/AppServiceControllerOptions.cs | 2 +- .../Mvc/AspNetCoreApiDescriptionModelProvider.cs | 4 ++-- ...viceCollectionDynamicHttpClientProxyExtensions.cs | 12 ++++++------ .../Client/DynamicProxying/ApiDescriptionFinder.cs | 7 +------ .../DynamicProxying/DynamicHttpClientProxyConfig.cs | 5 +---- .../Http/Modeling/ControllerApiDescriptionModel.cs | 5 +++++ .../ControllerInterfaceApiDescriptionModel.cs | 2 +- .../Abp/Http/Modeling/ModuleApiDescriptionModel.cs | 2 +- 9 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs index 66366af15b..acc3e9e53c 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs @@ -244,7 +244,7 @@ namespace Volo.Abp.AspNetCore.Mvc protected virtual string GetModuleNameOrDefault(Type controllerType) { return GetControllerSettingOrNull(controllerType)?.ModuleName ?? - ModuleApiDescriptionModel.DefaultServiceModuleName; + ModuleApiDescriptionModel.DefaultModuleName; } [CanBeNull] diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AppServiceControllerOptions.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AppServiceControllerOptions.cs index 7f12bb75a0..d7d4911a2c 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AppServiceControllerOptions.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AppServiceControllerOptions.cs @@ -29,7 +29,7 @@ namespace Volo.Abp.AspNetCore.Mvc }; } - public AbpControllerAssemblySettingBuilder CreateFor(Assembly assembly, string moduleName = ModuleApiDescriptionModel.DefaultServiceModuleName) + public AbpControllerAssemblySettingBuilder CreateFor(Assembly assembly, string moduleName = ModuleApiDescriptionModel.DefaultModuleName) { var setting = new AbpControllerAssemblySetting(assembly, moduleName); ControllerAssemblySettings.Add(setting); diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs index 4647fb1a1f..f99296a6b3 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs @@ -158,7 +158,7 @@ namespace Volo.Abp.AspNetCore.Mvc { if (controllerType == null) { - return ModuleApiDescriptionModel.DefaultServiceModuleName; + return ModuleApiDescriptionModel.DefaultModuleName; } foreach (var controllerSetting in _options.AppServiceControllers.ControllerAssemblySettings) @@ -175,7 +175,7 @@ namespace Volo.Abp.AspNetCore.Mvc return areaAttr.RouteValue; } - return ModuleApiDescriptionModel.DefaultServiceModuleName; + return ModuleApiDescriptionModel.DefaultModuleName; } } } diff --git a/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs b/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs index 9a0e2d287d..9dced9c284 100644 --- a/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs +++ b/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs @@ -18,7 +18,7 @@ namespace Microsoft.Extensions.DependencyInjection this IServiceCollection services, Assembly assembly, string baseUrl, - string moduleName = ModuleApiDescriptionModel.DefaultServiceModuleName) + string moduleName = ModuleApiDescriptionModel.DefaultModuleName) { //TODO: Add option to change type filter @@ -28,22 +28,22 @@ namespace Microsoft.Extensions.DependencyInjection foreach (var serviceType in serviceTypes) { - services.AddHttpClientProxy(serviceType, baseUrl, moduleName); + services.AddHttpClientProxy(serviceType, baseUrl); } return services; } - public static IServiceCollection AddHttpClientProxy(this IServiceCollection services, string baseUrl, string moduleName = ModuleApiDescriptionModel.DefaultServiceModuleName) + public static IServiceCollection AddHttpClientProxy(this IServiceCollection services, string baseUrl) { - return services.AddHttpClientProxy(typeof(T), baseUrl, moduleName); + return services.AddHttpClientProxy(typeof(T), baseUrl); } - public static IServiceCollection AddHttpClientProxy(this IServiceCollection services, Type type, string baseUrl, string moduleName = ModuleApiDescriptionModel.DefaultServiceModuleName) + public static IServiceCollection AddHttpClientProxy(this IServiceCollection services, Type type, string baseUrl) { services.Configure(options => { - options.HttpClientProxies[type] = new DynamicHttpClientProxyConfig(moduleName, baseUrl, type); + options.HttpClientProxies[type] = new DynamicHttpClientProxyConfig(baseUrl, type); }); var interceptorType = typeof(DynamicHttpProxyInterceptor<>).MakeGenericType(type); diff --git a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs index 90eee9ae9f..64b17fb01c 100644 --- a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs +++ b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs @@ -25,14 +25,9 @@ namespace Volo.Abp.Http.Client.DynamicProxying foreach (var module in apiDescription.Modules.Values) { - if (module.Name != proxyConfig.ModuleName) - { - continue; - } - foreach (var controller in module.Controllers.Values) { - if (controller.Interfaces.All(i => i.TypeAsString != proxyConfig.Type.FullName)) + if (!controller.Implements(proxyConfig.Type)) { continue; } diff --git a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpClientProxyConfig.cs b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpClientProxyConfig.cs index 20df2dfd7e..5abc248cbe 100644 --- a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpClientProxyConfig.cs +++ b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpClientProxyConfig.cs @@ -6,14 +6,11 @@ namespace Volo.Abp.Http.Client.DynamicProxying { public string BaseUrl { get; } - public string ModuleName { get; } - public Type Type { get; } - public DynamicHttpClientProxyConfig(string moduleName, string baseUrl, Type type) + public DynamicHttpClientProxyConfig(string baseUrl, Type type) { BaseUrl = baseUrl; - ModuleName = moduleName; Type = type; } } diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs index b4bd4df80e..ff1a2301ea 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs @@ -66,5 +66,10 @@ namespace Volo.Abp.Http.Modeling return subModel; } + + public bool Implements(Type interfaceType) + { + return Interfaces.Any(i => i.TypeAsString == interfaceType.AssemblyQualifiedName); + } } } \ No newline at end of file diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerInterfaceApiDescriptionModel.cs b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerInterfaceApiDescriptionModel.cs index 3868ec94f9..78b62d726f 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerInterfaceApiDescriptionModel.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerInterfaceApiDescriptionModel.cs @@ -16,7 +16,7 @@ namespace Volo.Abp.Http.Modeling { return new ControllerInterfaceApiDescriptionModel { - TypeAsString = type.FullName + TypeAsString = type.AssemblyQualifiedName }; } } diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs index 78b9f1ebbf..67366c01ad 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs @@ -10,7 +10,7 @@ namespace Volo.Abp.Http.Modeling /// /// "app". /// - public const string DefaultServiceModuleName = "app"; + public const string DefaultModuleName = "app"; public string Name { get; set; }