问题描述:

Our Web Project has 3 usual layers:

Presentation Layer ( PL )

Business Layer ( BLL )

Data access Layer ( DAL )

We should produce some URLs in BLL but URL helpers and URL generation functionalities are located in PL.

In our case we want to produce URLs and send them to telegram Bot. but I believe in some other cases also it will be required.

How we can generate URLs in BLL in a correct way when URL generation functionality lies in PL?

网友答案:

Define an interface IUrlGenerator (or something like it) in the BLL, and inject it in the class in the BLL where you want to use it.

Create an implementation of the interface IUrlGenerator in the PL since you can implement it there correctly.

Use DI to wire up the classes and interfaces.

相关阅读:
Top