/// <summary> /// Log to log specifying the plugin that caused the message /// </summary> /// <param name="sender">The <see cref="ClientPlugin.Models.IGenericInliner"/> plugin that called this</param> /// <param name="msg">Message to display</param> public static void Log(IGenericInliner sender, string msg) { MessageReceived(null, new LogReceivedEventArgs() { Message = msg, Sender = sender }); }
/// <summary> /// Add a plugin row to a listview /// </summary> /// <param name="lv">The listview to add to</param> /// <param name="plugin">The plugin to add a row for</param> public static void AddPluginRow(this ListView lv, IGenericInliner plugin) { ListViewItem lvi = new ListViewItem(); lvi.Text = plugin.Name; lvi.SubItems.Add(plugin.Description); lvi.SubItems.Add(plugin.Author); lvi.SubItems.Add(string.Format("v{0}", plugin.Version)); lvi.SubItems.Add(plugin.Controls.Count > 0 ? "Yes" : "No"); lv.Items.Add(lvi); }
/// <summary> /// Load a specific plugin from the 'Plugins' folder /// </summary> /// <param name="module">Name of the dll file (without extension)</param> /// <returns>An instance of the plugin</returns> public static IGenericInliner LoadFrom(string module) { try { string filePath = Environment.CurrentDirectory + "\\Plugins\\" + module + ".dll"; Assembly asm = Assembly.LoadFrom(filePath); Type pluginType = typeof(IGenericInliner); ICollection <Type> pluginTypes = new List <Type>(); if (asm != null) { Type[] types = asm.GetTypes(); foreach (Type type in types) { if (type.IsInterface || type.IsAbstract) { continue; } else { if (type.GetInterface(pluginType.FullName) != null) { pluginTypes.Add(type); } } } } IGenericInliner loadedPlugin = null; foreach (Type type in pluginTypes) { IGenericInliner plugin = (IGenericInliner)Activator.CreateInstance(type); loadedPlugin = plugin; LoadedPlugins.Add(plugin); } return(loadedPlugin); } catch (Exception) { return(null); } }