Reputation: 718
I have ProjectA and ProjectB. ProjectA can work independently without any dependency of ProjectB. Now, I like to enable some modules/features in ProjectA only if the ProjectB is added as a reference in ProjectA. How to achieve this?
I have tried by adding conditional compilation in the needed modules/features in ProjectA like below.
#if ProjB
{
..
}
#endif
But how can I enable these conditional compilation constants by checking a condition that the "ProjectB" is referenced to "ProjectA". Also, I do not need "ProjectB" to be referenced always in "ProjectA". Still the "ProjectA" need to work independently in some cases.
Upvotes: 1
Views: 53
Reputation: 30205
You can use something like Plugin pattern. E.g.:
IPlugin
with Load
methodYou can define a special interface (multiple interfaces) that both projects will know about. Then your plugin (ProjectB) will provide this interface with all the methods that you want to call.
Upvotes: 1