I have a simple plugin system in a piece of code I have written. Basically, it takes a Type, which inherits from a base class, and calls “CreateInstance” on it. I then invoke the methods in this instance. The super class lives in an SDK DLL and contains no special logic/code, just skeleton methods which are overridden when a plugin is made.
I want to be able to make an object available to the plugin developers, called “SystemLog”, which will let them write log output. My question is, how can I populate this object when I create the instance, unless I make it public with get/set accessors? I would like it to be read-only to the plugin developer, as I don’t want them overwriting it in some way.
I see two questions here:
Let me start from the 2-nd one. You can declare something like
And implement simple kind of wrapper on top of the SystemLog (instance of this wrapper you could pass to the plugins). So plugins know only about ISystemLoggger interface and not about any kind of it’s implementation