diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs index 6b06c2854b..4700509ea3 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/ConventionalControllerSetting.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using System.Reflection; +using Volo.Abp.Application.Services; using Volo.Abp.Reflection; namespace Volo.Abp.AspNetCore.Mvc.Conventions; @@ -48,6 +49,11 @@ public class ConventionalControllerSetting [CanBeNull] public Func TypePredicate { get; set; } + /// + /// Default value: All. + /// + public ApplicationServiceTypes ApplicationServiceTypes { get; set; } = ApplicationServiceTypes.All; + [CanBeNull] public Action ControllerModelConfigurer { get; set; } @@ -78,6 +84,7 @@ public class ConventionalControllerSetting { var types = Assembly.GetTypes() .Where(IsRemoteService) + .Where(IsPreferredApplicationServiceType) .WhereIf(TypePredicate != null, TypePredicate); foreach (var type in types) @@ -85,7 +92,7 @@ public class ConventionalControllerSetting ControllerTypes.Add(type); } } - + public IReadOnlyList GetControllerTypes() { return ControllerTypes.ToImmutableList(); @@ -111,4 +118,24 @@ public class ConventionalControllerSetting return false; } -} + + private bool IsPreferredApplicationServiceType(Type type) + { + if (ApplicationServiceTypes == ApplicationServiceTypes.All) + { + return true; + } + + if (ApplicationServiceTypes == ApplicationServiceTypes.ApplicationServices) + { + return !type.IsDefined(typeof(IntegrationServiceAttribute)); + } + + if (ApplicationServiceTypes == ApplicationServiceTypes.IntegrationServices) + { + return type.IsDefined(typeof(IntegrationServiceAttribute)); + } + + return true; + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Services/ApplicationServiceTypes.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Services/ApplicationServiceTypes.cs new file mode 100644 index 0000000000..a9bba71f61 --- /dev/null +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Services/ApplicationServiceTypes.cs @@ -0,0 +1,22 @@ +using System; + +namespace Volo.Abp.Application.Services; + +[Flags] +public enum ApplicationServiceTypes : byte +{ + /// + /// Only application services without . + /// + ApplicationServices = 1, + + /// + /// Application services with . + /// + IntegrationServices = 2, + + /// + /// All application services. + /// + All = ApplicationServices | IntegrationServices +} \ No newline at end of file