Browse Source
Merge pull request #15309 from abpframework/set-defaults-feature-definition
Set defaults while adding features
pull/15314/head
maliming
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
10 additions and
4 deletions
-
framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureCheckerBase.cs
-
framework/src/Volo.Abp.Features/Volo/Abp/Features/FeatureDefinition.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.Domain/Volo/Abp/FeatureManagement/FeatureDefinitionRecord.cs
-
modules/feature-management/test/Volo.Abp.FeatureManagement.EntityFrameworkCore.Tests/Volo/Abp/FeatureManagement/EntityFrameworkCore/AbpFeatureManagementEntityFrameworkCoreTestModule.cs
|
|
@ -11,7 +11,7 @@ public abstract class FeatureCheckerBase : IFeatureChecker, ITransientDependency |
|
|
public virtual async Task<bool> IsEnabledAsync(string name) |
|
|
public virtual async Task<bool> IsEnabledAsync(string name) |
|
|
{ |
|
|
{ |
|
|
var value = await GetOrNullAsync(name); |
|
|
var value = await GetOrNullAsync(name); |
|
|
if (value == null) |
|
|
if (value.IsNullOrEmpty()) |
|
|
{ |
|
|
{ |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
@ -100,11 +100,11 @@ public class FeatureDefinition : ICanCreateChildFeature |
|
|
bool isVisibleToClients = true, |
|
|
bool isVisibleToClients = true, |
|
|
bool isAvailableToHost = true) |
|
|
bool isAvailableToHost = true) |
|
|
{ |
|
|
{ |
|
|
Name = name; |
|
|
Name = Check.NotNullOrWhiteSpace(name, nameof(name)); |
|
|
DefaultValue = defaultValue; |
|
|
DefaultValue = defaultValue; |
|
|
DisplayName = displayName ?? new FixedLocalizableString(name); |
|
|
DisplayName = displayName ?? new FixedLocalizableString(name); |
|
|
Description = description; |
|
|
Description = description; |
|
|
ValueType = valueType; |
|
|
ValueType = valueType ?? new ToggleStringValueType(); |
|
|
IsVisibleToClients = isVisibleToClients; |
|
|
IsVisibleToClients = isVisibleToClients; |
|
|
IsAvailableToHost = isAvailableToHost; |
|
|
IsAvailableToHost = isAvailableToHost; |
|
|
|
|
|
|
|
|
|
|
|
@ -70,7 +70,7 @@ public class FeatureDefinitionRecord : BasicAggregateRoot<Guid>, IHasExtraProper |
|
|
DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), FeatureDefinitionRecordConsts.MaxDisplayNameLength); |
|
|
DisplayName = Check.NotNullOrWhiteSpace(displayName, nameof(displayName), FeatureDefinitionRecordConsts.MaxDisplayNameLength); |
|
|
|
|
|
|
|
|
Description = Check.Length(description, nameof(description), FeatureDefinitionRecordConsts.MaxDescriptionLength); |
|
|
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; |
|
|
IsVisibleToClients = isVisibleToClients; |
|
|
IsAvailableToHost = isAvailableToHost; |
|
|
IsAvailableToHost = isAvailableToHost; |
|
|
|
|
|
@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore.Storage; |
|
|
using Volo.Abp.EntityFrameworkCore; |
|
|
using Volo.Abp.EntityFrameworkCore; |
|
|
using Volo.Abp.EntityFrameworkCore.Sqlite; |
|
|
using Volo.Abp.EntityFrameworkCore.Sqlite; |
|
|
using Volo.Abp.Modularity; |
|
|
using Volo.Abp.Modularity; |
|
|
|
|
|
using Volo.Abp.Uow; |
|
|
|
|
|
|
|
|
namespace Volo.Abp.FeatureManagement.EntityFrameworkCore; |
|
|
namespace Volo.Abp.FeatureManagement.EntityFrameworkCore; |
|
|
|
|
|
|
|
|
@ -26,6 +27,11 @@ public class AbpFeatureManagementEntityFrameworkCoreTestModule : AbpModule |
|
|
abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection); |
|
|
abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
Configure<AbpUnitOfWorkDefaultOptions>(options => |
|
|
|
|
|
{ |
|
|
|
|
|
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static SqliteConnection CreateDatabaseAndGetConnection() |
|
|
private static SqliteConnection CreateDatabaseAndGetConnection() |
|
|
|