diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceControllerFeatureProvider.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceControllerFeatureProvider.cs index 409ad3241f..a9165f1409 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceControllerFeatureProvider.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceControllerFeatureProvider.cs @@ -2,8 +2,6 @@ using System.Reflection; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -using Volo.Abp.Application.Services; -using Volo.Abp.Reflection; namespace Volo.Abp.AspNetCore.Mvc { @@ -18,29 +16,14 @@ namespace Volo.Abp.AspNetCore.Mvc protected override bool IsController(TypeInfo typeInfo) { - var type = typeInfo.AsType(); - - if (!typeof(IRemoteService).IsAssignableFrom(type) || - !typeInfo.IsPublic || typeInfo.IsAbstract || typeInfo.IsGenericType) - { - return false; - } - - var remoteServiceAttr = ReflectionHelper.GetSingleAttributeOrDefault(typeInfo); - - if (remoteServiceAttr != null && !remoteServiceAttr.IsEnabledFor(type)) - { - return false; - } - //TODO: Move this to a lazy loaded field for efficiency. var configuration = _application.ServiceProvider .GetRequiredService>().Value .AppServiceControllers .ControllerAssemblySettings - .GetSettingOrNull(type); + .GetSettingOrNull(typeInfo.AsType()); - return configuration != null && (configuration.TypePredicate == null || configuration.TypePredicate(type)); + return configuration != null; } } } \ No newline at end of file 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 98a9daca43..0952934df6 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 @@ -37,11 +37,14 @@ namespace Volo.Abp.AspNetCore.Mvc var controllerType = controller.ControllerType.AsType(); var configuration = GetControllerSettingOrNull(controllerType); - if (IsRemoteService(controllerType)) + //TODO: We can remove different behaviour for ImplementsRemoteServiceInterface. If there is a configuration, then it should be applied! + //TODO: If so, we can rename AppServiceControllers to ConventionalControllers! + //TODO: But also consider AbpControllerAssemblySetting.IsRemoteService method too..! + + if (ImplementsRemoteServiceInterface(controllerType)) { controller.ControllerName = controller.ControllerName.RemovePostFix(ApplicationService.CommonPostfixes); configuration?.ControllerModelConfigurer?.Invoke(controller); - //ConfigureArea(controller, configuration); ConfigureRemoteService(controller, configuration); } else @@ -328,7 +331,7 @@ namespace Volo.Abp.AspNetCore.Mvc return selector.AttributeRouteModel == null && selector.ActionConstraints.IsNullOrEmpty(); } - protected virtual bool IsRemoteService(Type controllerType) + protected virtual bool ImplementsRemoteServiceInterface(Type controllerType) { return typeof(IRemoteService).GetTypeInfo().IsAssignableFrom(controllerType); } diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerAssemblySetting.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerAssemblySetting.cs index eb3cdd144b..a99b87855e 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerAssemblySetting.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpControllerAssemblySetting.cs @@ -16,7 +16,7 @@ namespace Volo.Abp.AspNetCore.Mvc public Assembly Assembly { get; } [NotNull] - public List ControllerTypes { get; } + public HashSet ControllerTypes { get; } [NotNull] public string RootPath @@ -51,18 +51,21 @@ namespace Volo.Abp.AspNetCore.Mvc Assembly = assembly; RootPath = rootPath; - ControllerTypes = new List(); + ControllerTypes = new HashSet(); ApiVersion = new ApiVersion(1, 0); } public void Initialize() { - ControllerTypes.AddRange( - Assembly.GetTypes() - .Where(IsRemoteService) - .WhereIf(TypePredicate != null, TypePredicate) - ); + var types = Assembly.GetTypes() + .Where(IsRemoteService) + .WhereIf(TypePredicate != null, TypePredicate); + + foreach (var type in types) + { + ControllerTypes.Add(type); + } } private static bool IsRemoteService(Type type) 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 6179f860c6..3a2fdba255 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 @@ -164,7 +164,7 @@ namespace Volo.Abp.AspNetCore.Mvc foreach (var controllerSetting in _options.AppServiceControllers.ControllerAssemblySettings) { - if (Equals(controllerType.Assembly, controllerSetting.Assembly)) + if(controllerSetting.ControllerTypes.Contains(controllerType)) { return controllerSetting.RootPath; } diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ControllerAssemblySettingList.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ControllerAssemblySettingList.cs index c7701994bc..b59ac8c576 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ControllerAssemblySettingList.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ControllerAssemblySettingList.cs @@ -10,7 +10,7 @@ namespace Volo.Abp.AspNetCore.Mvc [CanBeNull] public AbpControllerAssemblySetting GetSettingOrNull(Type controllerType) { - return this.FirstOrDefault(controllerSetting => controllerSetting.Assembly == controllerType.Assembly); + return this.FirstOrDefault(controllerSetting => controllerSetting.ControllerTypes.Contains(controllerType)); } } } \ No newline at end of file diff --git a/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs index e0e74595e6..9a450b775c 100644 --- a/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs +++ b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs @@ -1,5 +1,4 @@ using System; -using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Modularity; @@ -19,7 +18,8 @@ namespace Volo.Abp.Identity { opts.RootPath = "identity"; opts.UrlControllerNameNormalizer = context => context.ControllerName.RemovePreFix("Identity"); - opts.ApiVersion = new ApiVersion(2, 0, "beta"); + + // }); }); }