Plugin based application with central saved settings

Arokh

Centurion
Joined
Apr 11, 2006
Messages
124
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:
Visual Basic:
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?
 
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?
 
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.
 
Back
Top