简体   繁体   中英

What are the marker types for assemblies in .NET?

What are the marker types for assemblies in .NET?

I am learning the AutoMapper through the tutorials and I come across the concept of the marker types for assemblies over here :

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

While searching for the answer to my question I come over this SO question. But I was not able to find the answer there.

I guess, that in scope of AutoMapper and your sample

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

it means any type from the particular assembly, which is used to "mark" the assembly for scanning for mapping profiles. Assemblies containing HomeController and Entity types will be scanned for getting a types inheriting from Profile for mapper configuration

AutoMapper will scan the designated assemblies for classes inheriting from Profile and add them to the configuration

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM