Exemple #1
0
        private void AddPlugin(string FileName)
        {
            Assembly pluginAssembly = Assembly.LoadFrom(FileName);

            foreach (Type pluginType in pluginAssembly.GetTypes())
            {
                if (pluginType.IsPublic)
                {
                    if (!pluginType.IsAbstract)
                    {
                        Type typeInterface = pluginType.GetInterface("PluginInterface.IPlugin", true);
                        if (typeInterface != null)
                        {
                            Types.Plugin newPlugin = new Types.Plugin();
                            newPlugin.AssemblyPath  = FileName;
                            newPlugin.Instance      = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                            newPlugin.Instance.Host = this;
                            newPlugin.Instance.Initialize();
                            this.colAvailablePlugins.Add(newPlugin);

                            newPlugin = null;
                        }

                        typeInterface = null;
                    }
                }
            }

            pluginAssembly = null;
        }
        private void AddPlugin(string FileName)
        {
            Assembly pluginAssembly = Assembly.LoadFrom(FileName);

            foreach (Type pluginType in pluginAssembly.GetTypes())
            {
                if (pluginType.IsPublic)
                {
                    if (!pluginType.IsAbstract)
                    {
                        Type typeInterface = pluginType.GetInterface("PluginInterface.IPlugin", true);
                        if (typeInterface != null)
                        {
                            Types.Plugin newPlugin = new Types.Plugin();
                            newPlugin.AssemblyPath = FileName;
                            newPlugin.Instance = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                            newPlugin.Instance.Host = this;
                            newPlugin.Instance.Initialize();
                            this.colAvailablePlugins.Add(newPlugin);

                            newPlugin = null;
                        }

                        typeInterface = null;
                    }
                }
            }

            pluginAssembly = null;
        }
Exemple #3
0
 /// <summary>
 /// Removes a plugin
 /// </summary>
 /// <param name="pluginToRemove">The Plugin to Remove</param>
 public void Remove(Types.Plugin pluginToRemove)
 {
     this.List.Remove(pluginToRemove);
 }
Exemple #4
0
 /// <summary>
 /// Add a plugin
 /// </summary>
 /// <param name="pluginToAdd">The Plugin to Add</param>
 public void Add(Types.Plugin pluginToAdd)
 {
     this.List.Add(pluginToAdd);
 }