Plugin Engine (design question)
-
I am attempting to add plugin support to a program I wrote. I have found many articles on Code Project, each showing how you can create objects from an assembly loaded at runtime. This is great, however, my original design made extensive use of inheritance. Now I'm trying to figure out how I can expose a "parent class" to a plugin. For example: Button inherits from Surface. Surface needs to be something that can be re-written by plugin developers, so that Button will now inherit the version of Surface in the plugin. Can this even be done? -Mike.
-
I am attempting to add plugin support to a program I wrote. I have found many articles on Code Project, each showing how you can create objects from an assembly loaded at runtime. This is great, however, my original design made extensive use of inheritance. Now I'm trying to figure out how I can expose a "parent class" to a plugin. For example: Button inherits from Surface. Surface needs to be something that can be re-written by plugin developers, so that Button will now inherit the version of Surface in the plugin. Can this even be done? -Mike.
I don't think you can do that (or even want to do that; plugins should have very limited set of functionality avalible to them; inserting them into the core of a aplication is not the best choice...)... But please correct me if I am wrong. -------------------------------------------------------- Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!
-
I am attempting to add plugin support to a program I wrote. I have found many articles on Code Project, each showing how you can create objects from an assembly loaded at runtime. This is great, however, my original design made extensive use of inheritance. Now I'm trying to figure out how I can expose a "parent class" to a plugin. For example: Button inherits from Surface. Surface needs to be something that can be re-written by plugin developers, so that Button will now inherit the version of Surface in the plugin. Can this even be done? -Mike.
Hello, This can be done, although it is not an easy road you want to travel.. Here late binding is not enough, but you also need to create code at runtime. I don't know exactly how to do this. Also several problems arise: what if more than one replacement for the surface class is found? What to do with errors that the plugin might cause? Etc. But I wonder, why do you want to give complete control over your application to some third party? Behind every great black man... ... is the police. - Conspiracy brother Blog[^]