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 IF
Here's one way to handle it with DI using Unity.
IUnityContainer container = new UnityContainer();
string customerNamespace = ConfigurationManager.AppSettings["CustomerNamespace"];
container.RegisterType(typeof(ISomeInterface),
Type.GetType(customerNamespace+".SomeImplementation"));
// ...
ISomeInterface instance = conainer.Resolve();
Where each customer has their own implementation of ISomeInterface
in a customer specific namespace.