Enhance the submodule loader and port the enhancements to the services base
parent
54ab7d7ceb
commit
b2111f6a19
|
@ -95,6 +95,20 @@ namespace OpenSim.Servers.Base
|
|||
}
|
||||
|
||||
public static T LoadPlugin<T>(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<T>(dllName, className, args);
|
||||
}
|
||||
|
||||
public static T LoadPlugin<T>(string dllName, string className, Object[] args) where T:class
|
||||
{
|
||||
string interfaceName = typeof(T).ToString();
|
||||
|
||||
|
@ -106,6 +120,11 @@ namespace OpenSim.Servers.Base
|
|||
{
|
||||
if (pluginType.IsPublic)
|
||||
{
|
||||
if (className != String.Empty &&
|
||||
pluginType.ToString() !=
|
||||
pluginType.Namespace + "." + className)
|
||||
continue;
|
||||
|
||||
Type typeInterface =
|
||||
pluginType.GetInterface(interfaceName, true);
|
||||
if (typeInterface != null)
|
||||
|
|
|
@ -35,6 +35,25 @@ namespace OpenSim.Services.Base
|
|||
public class ServiceBase
|
||||
{
|
||||
public T LoadPlugin<T>(string dllName) where T:class
|
||||
{
|
||||
return LoadPlugin<T>(dllName, new Object[0]);
|
||||
}
|
||||
|
||||
public T LoadPlugin<T>(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<T>(dllName, className, args);
|
||||
}
|
||||
|
||||
public T LoadPlugin<T>(string dllName, string className, Object[] args) where T:class
|
||||
{
|
||||
string interfaceName = typeof(T).ToString();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue