i've created my own plugin architecture for one of my programs.
Basicly Plugin is the base class for all of my plugins and say that i've plugins like PluginA : Plugin, PluginB : Plugin.
public class Plugin
{
private static Plugin _instance;
public static Plugin Instance { get { return Plugin._instance; } }
}
Now as usual each of my plugins have other stuff like forms and other classes. From that classes i want to access the current plugin instance like;
Plugin.Instance.Settings()
If i do assign _instance field in plugin ctor like;
public Plugin(GlobalSettings gs, PluginSettings ps)
{
Plugin._instance=this;
}
Then for each loaded plugin the Instance is overwritten and i get strange results like PluginB.Instance returning an instance of PluginA.
I know singleton does not seem the quite right way to do this, but i wasn't be able to come with another solution. Maybe a multiton can solve this, but i don't want my plugin writers to go for
Plugin.Instance["PluginB"]
all time which seems irrelevant.
Thanks for any help.