Browse Source
Merge pull request #23469 from abpframework/Disable-MapperlyAutoObjectMappingProvider
Disable `MapperlyAutoObjectMappingProvider` if AutoMapper used in app.
pull/23497/head
oykuermann
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
21 additions and
2 deletions
-
framework/src/Volo.Abp.Mapperly/Volo/Abp/Mapperly/AbpMapperlyModule.cs
|
|
|
@ -1,4 +1,6 @@ |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using System; |
|
|
|
using System.Linq; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Volo.Abp.Auditing; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
using Volo.Abp.ObjectExtending; |
|
|
|
@ -20,6 +22,23 @@ public class AbpMapperlyModule : AbpModule |
|
|
|
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
context.Services.AddMapperlyObjectMapper(); |
|
|
|
// This is the temporary solution, We will remove it in when all apps are migrated to Mapperly.
|
|
|
|
var disableMapperlyAutoObjectMappingProvider = false; |
|
|
|
|
|
|
|
var modules = context.Services.GetSingletonInstance<IAbpApplication>().Modules.ToList(); |
|
|
|
var autoMapperModuleIndex = modules.FindIndex(x => x.Type.FullName!.Equals("Volo.Abp.AutoMapper.AbpAutoMapperModule", StringComparison.OrdinalIgnoreCase)); |
|
|
|
if (autoMapperModuleIndex >= 0) |
|
|
|
{ |
|
|
|
var mapperlyModuleIndex = modules.FindIndex(x => x.Type == typeof(AbpMapperlyModule)); |
|
|
|
if (mapperlyModuleIndex > autoMapperModuleIndex) |
|
|
|
{ |
|
|
|
disableMapperlyAutoObjectMappingProvider = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!disableMapperlyAutoObjectMappingProvider) |
|
|
|
{ |
|
|
|
context.Services.AddMapperlyObjectMapper(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|