From b9f16b341e9d20777c1af271369f92df215785f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 3 Jan 2023 17:04:16 +0300 Subject: [PATCH] Set defaults while adding features --- .../Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs | 2 +- .../Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs | 4 ++-- .../Volo/Abp/FeatureManagement/FeatureDefinitionRecord.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs index f94be12ba1..893b5bbc1c 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs @@ -11,7 +11,7 @@ public abstract class FeatureCheckerBase : IFeatureChecker, ITransientDependency public virtual async Task IsEnabledAsync(string name) { var value = await GetOrNullAsync(name); - if (value == null) + if (value.IsNullOrEmpty()) { return false; } diff --git a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs index 5ea7377fd7..14cd0d405b 100644 --- a/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs +++ b/framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs @@ -100,11 +100,11 @@ public class FeatureDefinition : ICanCreateChildFeature bool isVisibleToClients = true, bool isAvailableToHost = true) { - Name = name; + Name = Check.NotNullOrWhiteSpace(name, nameof(name)); DefaultValue = defaultValue; DisplayName = displayName ?? new FixedLocalizableString(name); Description = description; - ValueType = valueType; + ValueType = valueType ?? new ToggleStringValueType(); IsVisibleToClients = isVisibleToClients; IsAvailableToHost = isAvailableToHost; diff --git a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureDefinitionRecord.cs b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureDefinitionRecord.cs index 618f52d7a1..0c181ab632 100644 --- a/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureDefinitionRecord.cs +++ b/modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureDefinitionRecord.cs @@ -70,7 +70,7 @@ public class FeatureDefinitionRecord : BasicAggregateRoot, IHasExtraProper DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), FeatureDefinitionRecordConsts.MaxDisplayNameLength); Description = Check.Length(description, nameof(description), FeatureDefinitionRecordConsts.MaxDescriptionLength); - DefaultValue = Check.NotNullOrWhiteSpace(defaultValue, nameof(defaultValue), FeatureDefinitionRecordConsts.MaxDefaultValueLength); + DefaultValue = Check.Length(defaultValue, nameof(defaultValue), FeatureDefinitionRecordConsts.MaxDefaultValueLength); IsVisibleToClients = isVisibleToClients; IsAvailableToHost = isAvailableToHost;