c# - Xamarin - AutoMapper 在初始化后添加配置文件
问题描述
我有一个使用 Automapper 的 Xamarin 应用程序,但我有很多profiles
.
如果我尝试profiles
在应用程序 Init 中加载所有这些,则需要几秒钟。
我想用一些基本配置文件初始化映射器,然后当我需要其他配置文件时,我想将它们添加到主配置中。
public static MapperConfiguration InitAutoMapper()
{
MapperConfiguration mapperConfiguration = new MapperConfiguration(cfg =>
{
cfg.SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
cfg.DestinationMemberNamingConvention = new LowerUnderscoreNamingConvention();
cfg.AddProfile<BaseProfile>();
cfg.AddProfile<ComboProfile>();
});
return mapperConfiguration;
}
public class MyViewModel : BaseViewModel {
public MyViewModel() {
// How can I add here the "MyViewModelProfile" to mapperConfiguration?
}
}
我怎样才能做到这一点?
编辑
与使用的配置文件和解析器链接。
解决方案
推荐阅读
- angular - 如何使用节点包“ng-multiselect-dropdown”加载动态数据
- ajax - 使用 HTTP DELETE 请求 (JavaScript) 配置删除按钮
- c# - 在 C# 中删除子文件夹中的 Azure Blob - 不删除子文件夹
- php - FB未定义javascript错误codeignitor facebook登录
- sas - 如何在sas中生成相同的随机变量
- php - Laravel 5.4、Passport 和 Angular 7 不能很好地结合在一起
- c# - 在 Start.cs 中添加 UseHsts() 有什么意义
- r - 有没有办法不用 R 中的 ckanr 下载整个 CKAN 数据包?
- java - 获取数组列表中缺少的数字
- tensorflow - 您如何管理 100 台虚拟服务器进行推理?