/// <summary> /// Add a plugin to the collection. /// </summary> /// <param name="plugin">Plugin to add (IAstroGrepPlugin)</param> /// <returns>Position of plugin in collection</returns> /// <history> /// [Curtis_Beard] 07/28/2006 Created /// </history> public static int Add(IAstroGrepPlugin plugin) { PluginWrapper wrapper = new PluginWrapper(plugin, string.Empty, plugin.Name, true, true); return(__PluginCollection.Add(wrapper)); }
/// <summary> /// Initializes a new instance of the PluginWrapper class. /// </summary> /// <param name="plugin">IAstroGrepPlugin</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> /// <history> /// [Curtis_Beard] 07/31/2006 Created /// </history> public PluginWrapper(IAstroGrepPlugin plugin, string assemblyPath, string assemblyName, bool internalPlugin, bool enabled) { __Plugin = plugin; __Path = assemblyPath; __Name = assemblyName; __Internal = internalPlugin; __Enabled = enabled; }
/// <summary> /// Initializes a new instance of the PluginWrapper class. /// </summary> /// <param name="plugin">IAstroGrepPlugin</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> /// <history> /// [Curtis_Beard] 07/31/2006 Created /// </history> public PluginWrapper(IAstroGrepPlugin 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> /// <history> /// [Curtis_Beard] 09/08/2006 Created /// [Curtis_Beard] 06/28/2007 CHG: make all plugins external and enabled by default /// [Curtis_Beard] 04/08/2015 CHG: add logging /// </history> 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("libAstroGrep.Plugin.IAstroGrepPlugin", true); if (objInterface != null) { // Load dll // Create and return class instance object objPlugin = dll.CreateInstance(objType.FullName); IAstroGrepPlugin plugin = (IAstroGrepPlugin)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; }
/// <summary> /// Load a plugin from file. /// </summary> /// <param name="path">Full file path to plugin</param> /// <returns>PluginWrapper containing plugin</returns> /// <history> /// [Curtis_Beard] 09/08/2006 Created /// </history> 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("AstroGrepBase.IAstroGrepPlugin", true); if (objInterface != null) { // Load dll // Create and return class instance object objPlugin = dll.CreateInstance(objType.FullName); IAstroGrepPlugin plugin = (IAstroGrepPlugin)objPlugin; PluginWrapper wrapper = new PluginWrapper(plugin, path, dll.FullName, true, false); return(wrapper); } } } } } catch {} return(null); }
/// <summary> /// Add a plugin to the collection. /// </summary> /// <param name="plugin">Plugin to add (IAstroGrepPlugin)</param> /// <returns>Position of plugin in collection</returns> /// <history> /// [Curtis_Beard] 07/28/2006 Created /// </history> public static int Add(IAstroGrepPlugin plugin) { PluginWrapper wrapper = new PluginWrapper(plugin, string.Empty, plugin.Name, true, true); return __PluginCollection.Add(wrapper); }
/// <summary> /// Display the plugin details. /// </summary> /// <param name="plugin">IAstroGrepPlugin to load</param> /// <history> /// [Curtis_Beard] 09/05/2006 Created /// </history> private void LoadPluginDetails(IAstroGrepPlugin plugin) { lblPluginName.Text = plugin.Name; lblPluginVersion.Text = plugin.Version; lblPluginAuthor.Text = plugin.Author; lblPluginDescription.Text = plugin.Description; }