We are working on a .NET desktop application written in C# and WPF, that communicates with a REST API server. The software has a layered design and consists of multiple projects.
- One project for the presentation and ViewModels (we follow the MVVM pattern).
- One project for the domain layer. The business logic like services and model classes.
- One project for the implementation of the data layer. (In this case mainly the communication with the REST API). In the future there could be more projects for the data layer, that all have different implementations of data-ralated interfaces that are defined in the 'domain' project.
Our REST API provides an endpoint for loading images, and we want to create a service in the domain layer that makes it possible to load those images. This would mean the service class could look something like:
public class ImageService
{
public BitmapImage GetImage(int imageId)
{
// ...
}
}
But the above class has a dependency to BitmapImage
, or in other words: PresentationCore.dll
. This seems to be no good for a service class in a domain layer.
At the same time, it would be very useful to have this kind of service.
On one hand, BitmapImage
lets me think of a typical UI related object, but on the other hand BitmapImage
seems to be suitable because you could consider it as
a standalone class representing an image, and it is usable without any UI context (I mean, it's not a UI control/layout, doesn't depend on other UI related classes, etc.)
The problem is: is it acceptable to have a dependency to PresentationCore.dll
in a project that's a pure logical domain layer.
Also, a reference PresentationCore.dll
implies that the project could contain more usages of classes in that DLL, and possibly makes it unclear why that DLL is referenced at all. Maybe even the mistake/temptation exists someone's going to use UI related objects from this DLL?
What would be a solution for loading images in this case?