aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Servers/Base/ServerUtils.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Servers/Base/ServerUtils.cs')
-rw-r--r--OpenSim/Servers/Base/ServerUtils.cs35
1 files changed, 34 insertions, 1 deletions
diff --git a/OpenSim/Servers/Base/ServerUtils.cs b/OpenSim/Servers/Base/ServerUtils.cs
index 58d2b2b..4e8f472 100644
--- a/OpenSim/Servers/Base/ServerUtils.cs
+++ b/OpenSim/Servers/Base/ServerUtils.cs
@@ -27,11 +27,12 @@
27 27
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Reflection;
30using System.Xml; 31using System.Xml;
31using System.Xml.Serialization; 32using System.Xml.Serialization;
32using System.Text; 33using System.Text;
33 34
34namespace OpenSim.Servers.AssetServer 35namespace OpenSim.Servers.Base
35{ 36{
36 public static class ServerUtils 37 public static class ServerUtils
37 { 38 {
@@ -92,5 +93,37 @@ namespace OpenSim.Servers.AssetServer
92 93
93 return ret; 94 return ret;
94 } 95 }
96
97 public static T LoadPlugin<T>(string dllName, Object[] args) where T:class
98 {
99 string interfaceName = typeof(T).ToString();
100
101 try
102 {
103 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
104
105 foreach (Type pluginType in pluginAssembly.GetTypes())
106 {
107 if (pluginType.IsPublic)
108 {
109 Type typeInterface =
110 pluginType.GetInterface(interfaceName, true);
111 if (typeInterface != null)
112 {
113 T plug = (T)Activator.CreateInstance(pluginType,
114 args);
115
116 return plug;
117 }
118 }
119 }
120
121 return null;
122 }
123 catch (Exception e)
124 {
125 return null;
126 }
127 }
95 } 128 }
96} 129}