We are building an app for few customers, each has its own requirements along with the similar ones. We also want to keep all the code in the same app, not branch it, and the IFs is not good choice since it will be all over places.
I plan having the base classes for all. Then each customer will have its own class in which the override methods will do special logic.
How can we load the assemblies when compiling instead of doing this
public class BaseClass {
public string getEventId()
}
public class ClassForJohn:BaseClass {
[override]
public string getEventId()
}
public class ClassForAdam:BaseClass {
[override]
public string getEventId()
}
void UglyBranchingLogicSomewhere() {
BaseClass eventOject;
if("John"==ConfigurationManager.AppSettings["CustomerName"]){
eventOject = new ClassForJohn();
}else if("Adam"==ConfigurationManager.AppSettings["CustomerName"]){
eventOject = new ClassForAdam();
}else{
eventOject = new BaseClass ();
}
eventId = eventOject.getEventId();
}