Browse Source
Update module registration order check in AbpMapperlyModule
pull/23469/head
maliming
1 year ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
7 additions and
3 deletions
-
framework/src/Volo.Abp.Mapperly/Volo/Abp/Mapperly/AbpMapperlyModule.cs
|
|
@ -1,4 +1,5 @@ |
|
|
using System.Linq; |
|
|
using System; |
|
|
|
|
|
using System.Linq; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using Volo.Abp.Auditing; |
|
|
using Volo.Abp.Auditing; |
|
|
using Volo.Abp.Modularity; |
|
|
using Volo.Abp.Modularity; |
|
|
@ -22,8 +23,11 @@ public class AbpMapperlyModule : AbpModule |
|
|
public override void ConfigureServices(ServiceConfigurationContext context) |
|
|
public override void ConfigureServices(ServiceConfigurationContext context) |
|
|
{ |
|
|
{ |
|
|
// This is the temporary solution, We will remove it in when all apps are migrated to Mapperly.
|
|
|
// This is the temporary solution, We will remove it in when all apps are migrated to Mapperly.
|
|
|
var autoMapperModule = context.Services.FirstOrDefault(x => x.ServiceType.FullName == "Volo.Abp.AutoMapper.AbpAutoMapperModule"); |
|
|
var abpApplication = context.Services.GetSingletonInstance<IAbpApplication>(); |
|
|
if (autoMapperModule == null) |
|
|
var modules = abpApplication.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) |
|
|
{ |
|
|
{ |
|
|
context.Services.AddMapperlyObjectMapper(); |
|
|
context.Services.AddMapperlyObjectMapper(); |
|
|
} |
|
|
} |
|
|
|