From b2111f6a19235f38c90dad26c7bf041b950b0bd7 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 10 May 2009 22:31:10 +0000 Subject: Enhance the submodule loader and port the enhancements to the services base --- OpenSim/Services/Base/ServiceBase.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Base/ServiceBase.cs b/OpenSim/Services/Base/ServiceBase.cs index 800b172..c8a924b 100644 --- a/OpenSim/Services/Base/ServiceBase.cs +++ b/OpenSim/Services/Base/ServiceBase.cs @@ -36,6 +36,25 @@ namespace OpenSim.Services.Base { public T LoadPlugin(string dllName) where T:class { + return LoadPlugin(dllName, new Object[0]); + } + + public T LoadPlugin(string dllName, Object[] args) where T:class + { + string[] parts = dllName.Split(new char[] {':'}); + + dllName = parts[0]; + + string className = String.Empty; + + if (parts.Length > 1) + className = parts[1]; + + return LoadPlugin(dllName, className, args); + } + + public T LoadPlugin(string dllName, string className, Object[] args) where T:class + { string interfaceName = typeof(T).ToString(); try @@ -46,13 +65,17 @@ namespace OpenSim.Services.Base { if (pluginType.IsPublic) { + if (className != String.Empty && + pluginType.ToString() != + pluginType.Namespace + "." + className) + continue; + Type typeInterface = pluginType.GetInterface(interfaceName, true); if (typeInterface != null) { - T plug = (T)Activator.CreateInstance( - pluginAssembly.GetType( - pluginType.ToString())); + T plug = (T)Activator.CreateInstance(pluginType, + args); return plug; } -- cgit v1.1