Browse Source
Update Mapperly module registration logic
pull/23469/head
maliming
1 year ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
13 additions and
4 deletions
-
framework/src/Volo.Abp.Mapperly/Volo/Abp/Mapperly/AbpMapperlyModule.cs
|
|
|
@ -23,11 +23,20 @@ public class AbpMapperlyModule : AbpModule |
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
// This is the temporary solution, We will remove it in when all apps are migrated to Mapperly.
|
|
|
|
var abpApplication = context.Services.GetSingletonInstance<IAbpApplication>(); |
|
|
|
var modules = abpApplication.Modules.ToList(); |
|
|
|
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)); |
|
|
|
var mapperlyModuleIndex = modules.FindIndex(x => x.Type == typeof(AbpMapperlyModule)); |
|
|
|
if (mapperlyModuleIndex < autoMapperModuleIndex) |
|
|
|
if (autoMapperModuleIndex >= 0) |
|
|
|
{ |
|
|
|
var mapperlyModuleIndex = modules.FindIndex(x => x.Type == typeof(AbpMapperlyModule)); |
|
|
|
if (mapperlyModuleIndex > autoMapperModuleIndex) |
|
|
|
{ |
|
|
|
disableMapperlyAutoObjectMappingProvider = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!disableMapperlyAutoObjectMappingProvider) |
|
|
|
{ |
|
|
|
context.Services.AddMapperlyObjectMapper(); |
|
|
|
} |
|
|
|
|