From 7dd2a9accacb726b5807d0c8f42f85f240e0b3dd Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Thu, 20 Dec 2018 10:44:50 +0300 Subject: [PATCH] Register IOptions --- .../Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs | 12 ++++++++++-- .../Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs index df5d127d98..cac53d4611 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs @@ -75,14 +75,22 @@ namespace Volo.Abp.AspNetCore.Mvc var mvcCoreBuilder = context.Services.AddMvcCore(); context.Services.ExecutePreConfiguredActions(mvcCoreBuilder); + var abpMvcDataAnnotationsLocalizationOptions = context.Services.ExecutePreConfiguredActions(new AbpMvcDataAnnotationsLocalizationOptions()); + + context.Services + .AddSingleton>( + new OptionsWrapper( + abpMvcDataAnnotationsLocalizationOptions + ) + ); + var mvcBuilder = context.Services.AddMvc() .AddDataAnnotationsLocalization(options => { - var assemblyResources = context.Services.ExecutePreConfiguredActions(new AbpMvcDataAnnotationsLocalizationOptions()).AssemblyResources; options.DataAnnotationLocalizerProvider = (type, factory) => { - var resourceType = assemblyResources.GetOrDefault(type.Assembly); + var resourceType = abpMvcDataAnnotationsLocalizationOptions.AssemblyResources.GetOrDefault(type.Assembly); return factory.Create(resourceType ?? type); }; }) diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs index 94e020a365..6ffd7ebf54 100644 --- a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcTestModule.cs @@ -14,7 +14,6 @@ using Volo.Abp.Localization.Resources.AbpValidation; using Volo.Abp.MemoryDb; using Volo.Abp.Modularity; using Volo.Abp.TestApp; -using Volo.Abp.UI; using Volo.Abp.VirtualFileSystem; namespace Volo.Abp.AspNetCore.Mvc