Arokh Posted August 19, 2008 Posted August 19, 2008 Hi I'm writing an application which has script/plugin system. I want to provide a central place where settings are stored/recalled, dividing settings into private and public ones (per plugin). So basically my question is: Is there a reliable way to know from which dll the Property was called? (Without relying on the plugin, giving its name as a parameter) Simplified example: Class cMain Sub new(Main as cMain) Dim P1 = new cPlugin(Me) Dim P2 = new cPlugin2(Me) End Sub Public Property Settings(Key as String) as Object 'Get: Return GetSetting([Pluginname], Key) 'Set: GetSetting([Pluginname], Key) = Value End Property End Class Class cPlugin Sub new(Main as cMain) Main.Settings("Key") = [someObj] End Sub End Class Class cPlugin2 Sub new(Main as cMain) Main.Settings("Key") = [someObj] End Sub End Class I've read that stacktrace isn't really reliable, so is there any other way? Quote
Nate Bross Posted August 20, 2008 Posted August 20, 2008 Maybe I missed something, but if you are doing "plug-ins" you are probably using reflection, thus you should be able to get the name of the assembly, no? Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Leaders snarfblam Posted August 20, 2008 Leaders Posted August 20, 2008 Why not have a base class that plugins can inherit that implements a settings system (the base class can pass itself to the host to be used as a key for a settings node), or just require that the plugin class pass itself to the host to be used as a key. Either way, the host can obtain the type of the object that has passed itself and store the settings by that type so that they will be persisted between instances. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.