private void ExecuteAssembly(HostedPlugin plugin, string input) { var context = new CollectibleAssemblyContext(); var assemblyPath = Path.Combine(plugin.FilePath); using (var fs = new FileStream(assemblyPath, FileMode.Open, FileAccess.Read)) { var assembly = context.LoadFromStream(fs); var type = assembly.GetType("PluginSystem.Plugin"); var executeMethod = type.GetMethod("Execute"); var instance = Activator.CreateInstance(type); var dic = PluginResponses.GetOrCreate(plugin.Name); dic.Add(executeMethod.Invoke(instance, new object[] { input }).ToString()); } context.Unload(); }
public void RunPlugin(HostedPlugin plugin, string input) { ExecuteAssembly(plugin, input); RunGarbageCollection(); }