Mustafa Magdy
Mustafa Magdy

Reputation: 1330

dll custom business logic

I've a project where some business logic is separated to an DLL project, this DLL contains the business logic for this software for a specific customer.

Now I've a problem after another client with different rules want to implement the software, I need someway that the application load the appropriate dll according to the client using the software, considering that this dll contains same function names but different bodies.

I'm using c# 3.5, is there a way to do so ??

Upvotes: 1

Views: 1016

Answers (3)

Dharmendra Baghel
Dharmendra Baghel

Reputation: 11

If I understood your problem correctly than you are looking for business logic customization. You can achieve it through several ways. one of them I am describing here.

Create a folder on your application directory for customization DLLs. Create all your business objects through a wrapper. which will 1st check on customization dll for appropriate Class before any business object by using reflection else it will create business logic from regular class. hope this will help.

Upvotes: 1

Tom Anderson
Tom Anderson

Reputation: 10827

Code the business Logic against an Interface - IBusinessLogic.

You can keep both business logics in the same assembly, and use config based dependency injection to specify which business logic is used during the deployment to the customer.

Upvotes: 1

Patrick Karcher
Patrick Karcher

Reputation: 23603

Yes, you certainly can. You can branch the project, alter the implementation of the classes, keep the signatures of all the classes and class members the same, recompile, and your business logic will behave as you wish.

But, this is not good. You will have two different branches, with different implementations, for which you will have to keep the signatures in synch forever. And then you'll have another client, and another. This will be a nightmare that never ends.

Is is possible that the differing functionality can be separated out? You can:

  • put configuration in the database or configuration files (probably XML). A lot of your app should work based on tables or config files, for this reason.
  • you can implement plug-ins and providers for places where the code needs to be different.
  • kindof oldschool, but you can implement plug-and-play functionality using the part of CodeDom that compiles code (ignore the part about graphing out code). You can then put functionality in easily edited text files.
  • take a look at the Managed Extensibility Framework, built for just this type of thing.

Upvotes: 5

Related Questions