简体   繁体   中英

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 ??

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM