diff --git a/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs b/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs index e3fd273026..e20b60bf54 100644 --- a/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs +++ b/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs @@ -45,11 +45,8 @@ namespace Microsoft.Extensions.DependencyInjection AddHttpClientFactoryAndPolicy(services, remoteServiceConfigurationName, configureHttpClientBuilder); //TODO: Make a configuration option and add remoteServiceName inside it! - //TODO: Add option to change type filter - var serviceTypes = assembly.GetTypes().Where(t => - t.IsInterface && t.IsPublic && typeof(IRemoteService).IsAssignableFrom(t) - ); + var serviceTypes = assembly.GetTypes().Where(IsSuitableForDynamicClientProxying); foreach (var serviceType in serviceTypes) { @@ -155,7 +152,7 @@ namespace Microsoft.Extensions.DependencyInjection services.AddTransient(interceptorType); var interceptorAdapterType = typeof(AbpAsyncDeterminationInterceptor<>).MakeGenericType(interceptorType); - + var validationInterceptorAdapterType = typeof(AbpAsyncDeterminationInterceptor<>).MakeGenericType(typeof(ValidationInterceptor)); @@ -191,5 +188,21 @@ namespace Microsoft.Extensions.DependencyInjection return services; } + + /// + /// Checks wether the type is suitable to use with the dynamic proxying. + /// Currently the type is checked statically against some fixed conditions. + /// + /// Type to check + /// True, if the type is suitable for dynamic proxying. Otherwise false. + static bool IsSuitableForDynamicClientProxying(Type type) + { + //TODO: Add option to change type filter + + return type.IsInterface + && type.IsPublic + && !type.IsGenericType + && typeof(IRemoteService).IsAssignableFrom(type); + } } }