From dadafc8b1a3b700c17e195a10c6f8d2caf8fc078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 25 Mar 2018 15:27:02 +0300 Subject: [PATCH] Created ModelBuilderConfigurationOptions --- ...ServiceCollectionPreConfigureExtensions.cs | 6 ++++ src/Volo.Abp.Core/Volo/Abp/Check.cs | 11 +++++++ .../ModelBuilderConfigurationOptions.cs | 32 +++++++++++++++++++ .../AbpMultiTenancyAbstractionsModule.cs | 2 +- 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/Modeling/ModelBuilderConfigurationOptions.cs diff --git a/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionPreConfigureExtensions.cs b/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionPreConfigureExtensions.cs index b1b819495b..c3baab575e 100644 --- a/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionPreConfigureExtensions.cs +++ b/src/Volo.Abp.Core/Microsoft/Extensions/DependencyInjection/ServiceCollectionPreConfigureExtensions.cs @@ -12,6 +12,12 @@ namespace Microsoft.Extensions.DependencyInjection return services; } + public static TOptions ExecutePreConfiguredActions(this IServiceCollection services) + where TOptions : new() + { + return services.ExecutePreConfiguredActions(new TOptions()); + } + public static TOptions ExecutePreConfiguredActions(this IServiceCollection services, TOptions options) { services.GetPreConfigureActions().Configure(options); diff --git a/src/Volo.Abp.Core/Volo/Abp/Check.cs b/src/Volo.Abp.Core/Volo/Abp/Check.cs index 6eba3f58bc..acf716c9bd 100644 --- a/src/Volo.Abp.Core/Volo/Abp/Check.cs +++ b/src/Volo.Abp.Core/Volo/Abp/Check.cs @@ -19,6 +19,17 @@ namespace Volo.Abp return value; } + [ContractAnnotation("value:null => halt")] + public static T NotNull(T value, [InvokerParameterName] [NotNull] string parameterName, string message) + { + if (value == null) + { + throw new ArgumentNullException(parameterName, message); + } + + return value; + } + [ContractAnnotation("value:null => halt")] public static string NotNullOrWhiteSpace(string value, [InvokerParameterName] [NotNull] string parameterName) { diff --git a/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/Modeling/ModelBuilderConfigurationOptions.cs b/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/Modeling/ModelBuilderConfigurationOptions.cs new file mode 100644 index 0000000000..808ef80bb6 --- /dev/null +++ b/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/Modeling/ModelBuilderConfigurationOptions.cs @@ -0,0 +1,32 @@ +using JetBrains.Annotations; + +namespace Volo.Abp.EntityFrameworkCore.Modeling +{ + public class ModelBuilderConfigurationOptions + { + [NotNull] + public string TablePrefix + { + get => _tablePrefix; + set + { + Check.NotNull(value, nameof(value), $"{nameof(TablePrefix)} can not be null! Set to empty string if you don't want a table prefix."); + _tablePrefix = value; + } + } + private string _tablePrefix; + + [CanBeNull] + public string Schema { get; set; } + + public ModelBuilderConfigurationOptions( + [NotNull] string tablePrefix = "", + [CanBeNull] string schema = null) + { + Check.NotNull(tablePrefix, nameof(tablePrefix)); + + TablePrefix = tablePrefix; + Schema = schema; + } + } +} diff --git a/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/AbpMultiTenancyAbstractionsModule.cs b/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/AbpMultiTenancyAbstractionsModule.cs index efb8d4cff4..336369dd35 100644 --- a/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/AbpMultiTenancyAbstractionsModule.cs +++ b/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/AbpMultiTenancyAbstractionsModule.cs @@ -7,7 +7,7 @@ namespace Volo.Abp.MultiTenancy { [DependsOn(typeof(AbpDataModule))] [DependsOn(typeof(AbpSettingsModule))] - public class AbpMultiTenancyAbstractionsModule : AbpModule + public class AbpMultiTenancyAbstractionsModule : AbpModule //TODO: Rename to AbpMultiTenancyModule { public override void ConfigureServices(IServiceCollection services) {