1: private IPlugin LoadPlugin( string AssemblyFileName )
2: {
3: IPlugin PluginFound = null;
4: Type iPluginType = typeof(IPlugin);
5:
6: Assembly _Assembly = Assembly.LoadFrom(AssemblyFileName);
7:
8: if (_Assembly != null)
9: {
10: Type[] types = _Assembly.GetExportedTypes();
11:
12: foreach (Type t in types)
13: if (iPluginType.IsAssignableFrom(t))
14: {
15: IPlugin operation = Activator.CreateInstance(t) as IPlugin;
16:
17: if (operation != null)
18: {
19: PluginFound = operation;
20: break;
21: }
22: }
23: }
24:
25: return PluginFound;
26: }