So here is the problem:
I have some logic in my application that will be different on a client by client basis. What is the best way to do structure this so that it can be configured without any code changes. I have already added an appsetting to the config like so:
<add key="MyCalculationType" value="MyApp.Client1.Calculation,MyApp.Client1" />
In my core business logic:
ICalculation abcCalculation = CalculationFactory.GetManager(); // Uses appsetting to get type
abcCalculation.Calculate(this);
I have added a new project called MyApp.Client1, which I want to contain the client specific implementation of Calculate.
namespace MyApp.Client1
{
public class Calculation : ICalculation
{
public void Calculate(Order o)
{
// Calculate properties of order
}
}
}
I have not finished yet, so I can’t provide any output. At this stage I want to know, before I go any further, whether there is a better way of acheiving what I am trying to. One thing I don’t know for sure is where to put the ICalculation interface. I think the way I have it may give circular reference errors.
Many thanks
EDIT
As I suspected, the ICalculation interface is preventing me from building. Though not with a cyclic reference error; with a “Cannot resolve symbol” error.
ICalculationinterface can be inside your ConnectorBridge library, which manages access, subscribtion and communication of external plugins with host environment.Your application and (say) Calculation project, both contain the reference to ConnectorBridge. In this way Calculation can implement an
ICalculationinterface and appliaction get access to abstraction.Create a folder in your application, say Plugins and on startup of your app you scan content of that folder for DLL’s where is present type that implements
ICalculationinterface. ONe time the type is found (Calculator in this sepcific case) it’s created, and preserved in application for future execution.These are just a copuple of ideas, but concrete implementation, naturally, requires much more work.
Hope this helps.