Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted
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?

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

  • Leaders
Posted
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.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...