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

qqq*_*qqq 3 .net c# types .net-assembly automapper

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

我正在通过教程学习 AutoMapper,我marker types for assemblies这里遇到了over的概念:

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

在寻找我的问题的答案时,我遇到了这个问题。但我无法在那里找到答案。

Pav*_*ski 9

我想,在范围内AutoMapper和你的样本

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

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

AutoMapper 将扫描从 Profile 继承的类的指定程序集并将它们添加到配置中