public PulsarPlugin LoadPlugin(string assemblyPath) { if (!File.Exists(assemblyPath)) { throw new IOException($"Couldn't find file: {assemblyPath}"); } try { Assembly asm = Assembly.LoadFile(assemblyPath); Type pluginType = asm.GetTypes().FirstOrDefault(t => t.IsSubclassOf(typeof(PulsarPlugin))); if (pluginType != null) { PulsarPlugin plugin = Activator.CreateInstance(pluginType) as PulsarPlugin; activePlugins.Add(plugin.Name, plugin); OnPluginSuccessfullyLoaded?.Invoke(plugin.Name, plugin); Logger.Info($"Loaded Plugin: {plugin.Name} Version {plugin.Version} Author: {plugin.Author}"); return(plugin); } else { Logger.Info($"Skipping {Path.GetFileName(assemblyPath)}; couldn't find plugin entry point."); return(null); } } catch (Exception e) { Logger.Info($"Failed to load plugin: {Path.GetFileName(assemblyPath)}\n{e}"); return(null); } }
public string GetModName(string pluginName) { PulsarPlugin plugin = PluginManager.Instance.GetPlugin(pluginName); return($"{plugin.Name} {plugin.Version} MPF{plugin.MPFunctionality}"); }