A little background story on this question:
I'm writing a POS system for my local bar, which I would like to be plugin-enabled. For this particular problem I'll use the following scenario:
I've got a calculator class which, as the name suggests, does all the calculations involving products on the current receipt, VAT, etc. I want this class to be extendable by a plugin (in a different assembly) to add a functionality to use these special coins we use. The calculator simply loops through all the products on the receipt (which is passed in it's constructor) to calculate the total amount. The receipt class has a list of all the product objects that are on it. The built-in product class does not have any members related to coins, these are in another product class in the plugin assembly.
The question herein is, how do I make my main program dynamically select the correct class to use for products?
I was thinking of loading all the plugins into a list or dictionary and simply loop through them to check if an override for the product class exists and then use that, but I would still need some kind of common interface, which is not an option. I know exactly how to do it in PHP, but there one can edit/replace the source with an updated one at run/install time.
Thanks in advance, Thom.
EDIT: To simplify the problem: Is it possible to have an external plugin assembly extend a built-in assembly with new methods, without having to hard-code the method's names/delegates/whatever in the existing application?