。NET中程序集的标记类型是什么?

问题描述 投票:0回答:1

。NET中程序集的标记类型是什么?

我正在通过教程学习AutoMapper,并且在marker types for assemblies上遇到了here的概念:

// Or marker types for assemblies:
var configuration = new MapperConfiguration(cfg =>
    cfg.AddMaps(new [] {
        typeof(HomeController),
        typeof(Entity)
    });
);

[在寻找问题答案时,我遇到了this SO问题。但是我在那里找不到答案。

c# .net types automapper .net-assembly
1个回答
1
投票

我想是AutoMapper和您的样本

// Or marker types for assemblies:
var configuration = new MapperConfiguration(cfg =>
    cfg.AddMaps(new [] {
        typeof(HomeController),
        typeof(Entity)
    });
);

表示特定组件中的任何类型,用于“标记”该组件以扫描映射配置文件。将扫描包含HomeControllerEntity类型的程序集,以获取从Profile继承的类型以进行映射器配置

AutoMapper将扫描指定的程序集以继承类从配置文件并将其添加到配置中

© www.soinside.com 2019 - 2024. All rights reserved.