mercredi 14 mars 2018

Common interface without dependency to specific logic

Lets assume that I have 3 projects

  • Common
  • Web
  • Core

Web and Core have reference to Common. Idea is that Common project contains common interfaces for Web and Core.

Let assume that in both projects I have some mapping and I want to have common interface for this. For example on Web project I want use AutoMapper, and on Core project I want to use something else.

For AutoMapper I need interface.

    using AutoMapper;
    namespace Common.Mapper
    {
        public interface IMapperConfiguration
        {
            IMapper GetMapper();
        }
    }

This is working in Web project, but I cannot move this interface to Common project since this interface has dependency to AutoMapper (IMapper is from AutoMapper).

How to create common interface for this? Is there some design pattern that I can use?

Mapper is just an example. I would like to know how to resolve problems like this. Thank you for your help.

Aucun commentaire:

Enregistrer un commentaire