Search code examples
c#.netconfigurationbusiness-logicextensibility

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


Solution

  • 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.