Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

like image 244
danyolgiax Avatar asked Oct 11 '22 19:10

danyolgiax


2 Answers

I think in this case, MEF would be a better choice. Castle is more like a DI engine for business logic, useful for controlling the object life cycle, especially when you want to be able to switch the way the program works (multiple small threads or one single large operation in one thread).
MEF, on the other hand, strips you of the need to add a config file for this type of configuration. You just operate with libraries. I think MEF is best for client-side GUI forms.

like image 121
Alex Avatar answered Oct 17 '22 07:10

Alex


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.

like image 38
Eranga Avatar answered Oct 17 '22 08:10

Eranga