/// <summary> /// Add a plugin to the collection. /// </summary> /// <param name="plugin">Plugin to add (IbSearchPlugin)</param> /// <returns>Position of plugin in collection</returns> public static int Add(IbSearchPlugin plugin) { PluginWrapper wrapper = new PluginWrapper(plugin, string.Empty, plugin.Name, true, true, __PluginCollection.Count); __PluginCollection.Add(wrapper); return(__PluginCollection.Count - 1); }
/// <summary> /// Display the plugin details. /// </summary> /// <param name="plugin">IbSearchPlugin to load</param> private void LoadPluginDetails(IbSearchPlugin plugin) { lblPluginName.Text = plugin.Name; lblPluginVersion.Text = plugin.Version; lblPluginAuthor.Text = plugin.Author; lblPluginDescription.Text = plugin.Description; }
/// <summary> /// Initializes a new instance of the PluginWrapper class. /// </summary> /// <param name="plugin">IbSearchPlugin</param> /// <param name="assemblyPath">Fully qualified file path</param> /// <param name="assemblyName">Name of assembly</param> /// <param name="internalPlugin">If true the plugin is internal, False is external.</param> /// <param name="enabled">If true the plugin is enabled, False is disabled.</param> public PluginWrapper(IbSearchPlugin plugin, string assemblyPath, string assemblyName, bool internalPlugin, bool enabled, int index) { Plugin = plugin; AssemblyPath = assemblyPath; AssemblyName = assemblyName; Internal = internalPlugin; Enabled = enabled; Index = index; }
/// <summary> /// Load a plugin from file. /// </summary> /// <param name="path">Full file path to plugin</param> /// <returns>PluginWrapper containing plugin</returns> private static PluginWrapper LoadPlugin(string path) { try { Assembly dll = Assembly.LoadFrom(path); Type objInterface; // Loop through each type in the DLL foreach (Type objType in dll.GetTypes()) { // Only look at public types if (objType.IsPublic) { // Ignore abstract classes if (!((objType.Attributes & TypeAttributes.Abstract) == TypeAttributes.Abstract)) { // See if this type implements our interface objInterface = objType.GetInterface("libbSearch.Plugin.IbSearchPlugin", true); if (objInterface != null) { // Load dll // Create and return class instance object objPlugin = dll.CreateInstance(objType.FullName); IbSearchPlugin plugin = (IbSearchPlugin)objPlugin; PluginWrapper wrapper = new PluginWrapper(plugin, path, dll.FullName, false, true, 0); return(wrapper); } } } } } catch (Exception ex) { LogClient.Instance.Logger.Error("Unable to load plugin at {0} with message {1}", path, ex.Message); } return(null); }