Exemplo n.º 1
0
 private void AddPlugin(List <IDexterPlugin> pluginHandlerList, string dllFileName)
 {
     try
     {
         Assembly pluginAssembly = Assembly.LoadFrom(dllFileName);
         foreach (Type pluginType in pluginAssembly.GetTypes())
         {
             if (pluginType.IsPublic)
             {
                 if (!pluginType.IsAbstract)
                 {
                     Type typeInterface = pluginType.GetInterface("IDexterPlugin", true);
                     if (typeInterface != null)
                     {
                         AvailablePlugin newPlugin = new AvailablePlugin();
                         newPlugin.Instance = (IDexterPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                         pluginHandlerList.Add(newPlugin.Instance);
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         CliLog.Error("Plugin Loading failed:" + e.StackTrace);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Finds a plugin in the available Plugins
        /// </summary>
        /// <param name="pluginNameOrPath">The name or File path of the plugin to find</param>
        /// <returns>Available Plugin, or null if the plugin is not found</returns>
        public AvailablePlugin Find(string pluginNameOrPath)
        {
            AvailablePlugin toReturn = null;

            //Loop through all the plugins
            foreach (AvailablePlugin pluginOn in this.List)
            {
                //Find the one with the matching name or filename
                if ((pluginOn.Instance.PLUGIN_NAME.Equals(pluginNameOrPath)))
                {
                    toReturn = pluginOn;
                    break;
                }
            }
            return(toReturn);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Remove a Plugin to the collection of Available plugins
 /// </summary>
 /// <param name="pluginToRemove">The Plugin to Remove</param>
 public void Remove(AvailablePlugin pluginToRemove)
 {
     this.List.Remove(pluginToRemove);
 }
Exemplo n.º 4
0
        //A Simple Home-brew class to hold some info about our Available Plugins

        /// <summary>
        /// Add a Plugin to the collection of Available plugins
        /// </summary>
        /// <param name="pluginToAdd">The Plugin to Add</param>
        public void Add(AvailablePlugin pluginToAdd)
        {
            this.List.Add(pluginToAdd);
        }