public EditorPlugin(string fileName, AGSEditorController pluginEditorController) { Type mainClass = null; Assembly assembly = Assembly.LoadFile(Path.GetFullPath(fileName)); foreach (Type type in assembly.GetExportedTypes()) { if (type.IsClass) { foreach (Type iface in type.GetInterfaces()) { if (iface == typeof(IAGSEditorPlugin)) { if (mainClass != null) { throw new AGSEditorException("Plugin has multiple classes implementing IAGSEditorPlugin"); } mainClass = type; break; } } } } if (mainClass == null) { throw new AGSEditorException("Plugin does not contain any classes that implement IAGSEditorPlugin"); } VerifyRequiredAGSVersion(mainClass); ConstructorInfo ctor = mainClass.GetConstructor(new Type[] { typeof(IAGSEditor) }); if (ctor == null) { throw new AGSEditorException("Class '" + mainClass.Name + "' does not have a (IAGSEditor) constructor"); } _plugin = (IAGSEditorPlugin)ctor.Invoke(new object[] { pluginEditorController }); _fileName = fileName; }