private void RunPlugin(Plugin plug) { Type ty = GetTypeForFileName(plug.FileName, plug.Type);//Assembly.LoadFrom(plug.FileName).GetType(plug.Type); if (ty == null) { throw new Exception(string.Format("The plugin {0} could not load the type. Are yo missing the Assembly Filename? ", plug.Name)); } try { CheckAndRunDependencies(plug); object obj = Constructor.Create(ty); obj = InjectInputs(obj, plug); MethodInfo runMethod = ty.GetMethod(plug.RunMethod); runMethod.Invoke(obj, new object[] { }); PlugsRegistry.AddLoadedPlugin(plug, obj); PlugsRegistry.ExtractOutputs(obj); string parent = obj.GetType().BaseType.ToString(); if (parent == "System.Windows.Forms.Form" && WinForm == null) { this.WinForm = obj; } } catch (Exception e) { throw new Exception(string.Format("The plugin {0} couldn´t initialize", plug.Name), e); } }
private void InstallPlugin(Plugin plug) { try { if (!string.IsNullOrEmpty(plug.InstallMethod)) { Type ty = Type.GetType(plug.Type); MethodInfo installMethod = ty.GetMethod(plug.InstallMethod); installMethod.Invoke(Constructor.Create(ty), new object[] { }); } } catch (Exception e) { throw new Exception(string.Format("The plugin {0} couldn´t install", plug.Name), e); } }