Search code examples
c#dependency-injectionmefautofacmulti-tenant

Customize c# WinForm application for multiple customers


Think at this scenario:

I have a c# windows form application. This application was the same for all my customers. Now one of them needs to modify a form adding new textbox and new logic.

I obviously don't wanto to duplicate my application, and inserting IF statements with customer-Id to control the logic can easly drive to a spaghetti-style code.

I think that in this situation I can create a separate dll project for each customer; Inside I can write custom forms implements same interface as default form (and same for logic classes) and I can try to switch those dll via configuration file or build the project with the right customer dll (or using, for example, Windsor Castle for DI).

Is this a valid pattern? Exists a different way?

update

I try to list:


Solution

  • If you are developing a multitenant application, there are DI frameworks like Autofac which support this kind of customization. Take a look at this article

    You can also use your Source Control system to help you out. When you need to customize, create a branch and do the customization there so you do not have to duplicate your code.