From d2af13fb1f2baaaec86fa789e7e6773d00df590b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 16 Aug 2020 19:52:44 +0300 Subject: [PATCH] Also accept Name for RequiresGlobalFeatureAttribute. --- .../Mvc/Conventions/AbpServiceConvention.cs | 2 +- .../RequiresGlobalFeatureAttribute.cs | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs index 166640fe00..f19de585b9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Conventions/AbpServiceConvention.cs @@ -427,7 +427,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Conventions return true; } - return GlobalFeatureManager.Instance.IsEnabled(attribute.FeatureType); + return GlobalFeatureManager.Instance.IsEnabled(attribute.GetFeatureName()); } } } diff --git a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequiresGlobalFeatureAttribute.cs b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequiresGlobalFeatureAttribute.cs index 23ea10be81..69df268e97 100644 --- a/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequiresGlobalFeatureAttribute.cs +++ b/framework/src/Volo.Abp.GlobalFeatures/Volo/Abp/GlobalFeatures/RequiresGlobalFeatureAttribute.cs @@ -1,15 +1,28 @@ using System; +using JetBrains.Annotations; namespace Volo.Abp.GlobalFeatures { [AttributeUsage(AttributeTargets.Class)] public class RequiresGlobalFeatureAttribute : Attribute { - public Type FeatureType { get; } + public Type Type { get; } - public RequiresGlobalFeatureAttribute(Type featureType) + public string Name { get; } + + public RequiresGlobalFeatureAttribute([NotNull] Type type) + { + Type = Check.NotNull(type, nameof(type)); + } + + public RequiresGlobalFeatureAttribute([NotNull] string name) + { + Name = Check.NotNullOrWhiteSpace(name, nameof(name)); + } + + public virtual string GetFeatureName() { - FeatureType = featureType; + return Name ?? GlobalFeatureNameAttribute.GetName(Type); } } }