diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Servers/Base/ServerUtils.cs | 35 |
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 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Reflection; | ||
30 | using System.Xml; | 31 | using System.Xml; |
31 | using System.Xml.Serialization; | 32 | using System.Xml.Serialization; |
32 | using System.Text; | 33 | using System.Text; |
33 | 34 | ||
34 | namespace OpenSim.Servers.AssetServer | 35 | namespace 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 | } |