How to configure AutoMapper if there is no ASP.net application?

I use AutoMapper in a number of projects in my solution. These projects can be deployed independently on multiple servers.

The documentation for AutoMapper says:

If you use the static Mapper method, the configuration should only occur once in the AppDomain. This means the best place for the configuration code is in the launch application, for example, the Global.asax file for ASP.NET applications.

While some of the projects will be ASP.net - most of them are Windows class / service libraries.

Where should I configure my mappings in this case?

+3
source share
2 answers

, AppDomain, , . . AutoMapper, IoC (Windsor), , program.cs. , , , , .

, , , , , , .

+2

, .

    protected void Application_Start()
    {
        RegisterMaps();
    }

    private void RegisterMaps()
    {
        WebAutoMapperSettings.Register();
        BusinessLogicAutoMapperSettings.Register();
    }

, BusinessLogicAutoMapperSettings.Register(), BusinessLogic webservice

0

Source: https://habr.com/ru/post/1744810/


All Articles