Can you include only certain forms at compile time

We are developing two versions of the application. Not in the sense of a simple version and a standard version of the application, where one version will have limited functionality, etc. In fact, we will display different types of information in the application, depending on the version (the best way I can describe it without going into too many details).

To distinguish the two versions of the application that we examined using the conditional attribute and the #if directive (if there are other options or a better way than the two, I am open to suggestions). After some research and debate, we decided to go with the #if approach, since this will not include unnecessary code during the compilation process (whereas the conditional attribute will simply remove calls to methods that do not meet this condition, but include methods anyway ... if I'm not wrong). I understand that they are not mutually exclusive, so we can always mix and match, if necessary.

In any case ... What is interesting for us now if there is a way to only include some forms of Windows at compile time based on the version of the application that we are compiling. We shared all the logic, so forms are just forms, with very little code inside them (basically just calls to form manager classes that process all business logic). The form manager classes will contain some of the #if statements inside them, so the code can be reused in both versions of the application whenever possible (instead of creating two classes and putting a conditional attribute in classes ... although maybe this is what we should consider).

Does anyone know of a good way to do this?

TIA

UPDATE:

FYI , . , #if , , . .

+3
3

- OO: , , , .

[es] ( ).

.

+3

The solution proposed by ChrisW is probably the right way to do this. However, this may include many changes to your design, so here is another one: instead of several configurations for the same project, create another project with the same sources. The easiest way to do this is to create a copy of your .csproj file and include it in the solution

+1
source

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


All Articles