To check if there is any specific project reference (C # code, preprocessor directives ...)

I am new to C # /. NET, so I hope there is a solution to my problem.

I work with two different image processing libraries that have their own classes for representing images. Since I do not want to use these classes in my (private) class library, I want to implement my own "myImage" -Class, which should be a wrapper for both other classes. (Of course, I want to add the functionality of libraries if they are missing).

My problem is now basically this: the myImage class requires a reference to both libraries for compilation, however sometimes I would like to use the myImage class in projects in which only one library is available. It’s not difficult for me to “add” or “remove” links to my image class project, but I don’t want to comment on the code that refers to the missing library.

So my question is: is it possible to somehow determine that the link is set using the preprocessing directive or with attributes or with the code directly? Or is there even an even better solution for my problem (perhaps smart class design?)

thanks for the help

+3
source share
3 answers

I don’t think there is a preprocessor directive that will tell you if a link has been added.

: , , .

, 2 (. " | " ), , , . , , , #if, .

, , , .

+1

, . () , .

, MEF, API- .

2 , / .

+1

, , , , , .

, , , .
.
. , .

, , , .

If this is not applicable in your case, please explain in a bit more detail why you want to encapsulate the two libraries.

+1
source

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


All Articles