Exemple #1
0
        /// <summary>
        /// Reloads all plugins in the plugins directory
        /// </summary>
        public void ReloadPlugins()
        {
            if (!started)
            {
                throw new InvalidOperationException("PluginManager has not been started.");
            }
            lock (lockObject)
            {
                localLoader.Unload();
                localLoader = new LocalLoader(pluginDirectory);
                LoadUserAssemblies();

                changeTime = new DateTime(0);
                if (PluginsReloaded != null)
                {
                    PluginsReloaded(this, new EventArgs());
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Constructs a plugin manager
        /// </summary>
        /// <param name="pluginRelativePath">The relative path to the plugins directory</param>
        /// <param name="autoReload">Should auto reload on file changes</param>
        public PluginManager(string pluginRelativePath, bool autoReload)
        {
            this.autoReload = autoReload;
            string assemblyLoc      = Assembly.GetExecutingAssembly().Location;
            string currentDirectory = assemblyLoc.Substring(0, assemblyLoc.LastIndexOf(Path.DirectorySeparatorChar) + 1);

            pluginDirectory = Path.Combine(currentDirectory, pluginRelativePath);
            if (!pluginDirectory.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                pluginDirectory = pluginDirectory + Path.DirectorySeparatorChar;
            }

            localLoader = new LocalLoader(pluginDirectory);

            // Add the most common references since plugin authors can't control which references they
            // use in scripts.  Adding a reference later that already exists does nothing.
            AddReference("Accessibility.dll");
            AddReference("Microsoft.Vsa.dll");
            AddReference("System.Configuration.Install.dll");
            AddReference("System.Data.dll");
            AddReference("System.Design.dll");
            AddReference("System.DirectoryServices.dll");
            AddReference("System.Drawing.Design.dll");
            AddReference("System.Drawing.dll");
            AddReference("System.EnterpriseServices.dll");
            AddReference("System.Management.dll");
            AddReference("System.Runtime.Remoting.dll");
            AddReference("System.Runtime.Serialization.Formatters.Soap.dll");
            AddReference("System.Security.dll");
            AddReference("System.ServiceProcess.dll");
            AddReference("System.Web.dll");
            AddReference("System.Web.RegularExpressions.dll");
            AddReference("System.Web.Services.dll");
            AddReference("System.Windows.Forms.Dll");
            AddReference("System.XML.dll");
        }