I’m wondering what is the best way to insert customization adapters into an application. In principle, my application is divided into two assemblies: A Coreassembly containing all the business logic and the assembly UserInterfacecontaining the GUI, controller classes (I use the Passive View MVC template deviant) and some auxiliary classes. The assembly core is also used by some other applications .
My application is used by our company to process orders from other companies. The general process is the same for all companies, but here and there there are small deviations characteristic of the client. At the moment, these deviations are embedded directly in the kernel assembly, which smells. I want to separate these features, to integrate them in the best way into one object per client, so I have a central object containing all the client-specific details that I can add to the UserInterface assembly.
I was thinking about using events to achieve this. By adding some events to my main classes, my controller classes could pick up or unsubscribe using these rejections for specific clients.
I can think of two ways of doing this: adding these bindings manually or adding them automatically if deviant methods exist. I am thinking of something similar for the latter:
foreach (Order order in form.SelectedOrders) {
CustomerExtension customer = customerExtensions[order.Customer];
if(Exists(customer.StatusChanging(...))
OrderManager.StatusChanging += new StatusChangingEventHandler(customer.StatusChanging(...));
order.SetStatus(newStatus);
if(Exists(customer.StatusChanging(...))
OrderManager.StatusChanging -= new StatusChangingEventHandler(customer.StatusChanging(...));
}
I think I need to use Reflection to achieve this, but how viable is it for operations that need to be done many times?
Or are there better ways to add custom clicks while depriving me of centralizing client-based deviations?
[EDIT] Completely changed the question.
source
share