Esempio n. 1
0
        /// <summary>
        /// Attempts to load the specified plugin.  If the plugin is already loaded, this
        /// does nothing.  If not, the assembly is loaded an an instance is created.
        /// </summary>
        /// <param name="scriptIdent">Script identifier.</param>
        /// <param name="report">Report with errors and warnings.</param>
        /// <returns>True on success.</returns>
        public bool LoadPlugin(string scriptIdent, out FileLoadReport report)
        {
            // Make sure the most recent version is compiled.
            string dllPath = PluginDllCache.GenerateScriptDll(scriptIdent,
                                                              mProject.ProjectPathName, out report);

            if (dllPath == null)
            {
                return(false);
            }

            if (DomainManager == null)
            {
                if (mActivePlugins.TryGetValue(scriptIdent, out IPlugin plugin))
                {
                    return(true);
                }
                Assembly asm = Assembly.LoadFile(dllPath);
                plugin = PluginDllCache.ConstructIPlugin(asm);
                mActivePlugins.Add(scriptIdent, plugin);
                report = new FileLoadReport(dllPath);       // empty report
                return(true);
            }
            else
            {
                IPlugin plugin = DomainManager.PluginMgr.LoadPlugin(dllPath, scriptIdent);
                return(plugin != null);
            }
        }
Esempio n. 2
0
 private void CreateDomainManager()
 {
     // The project's UseMainAppDomainForPlugins value is theoretically mutable, so
     // don't try to assert it here.
     DomainMgr = new DomainManager(UseKeepAliveHack);
     DomainMgr.CreateDomain("Plugin Domain", PluginDllCache.GetPluginDirPath());
     DomainMgr.PluginMgr.SetFileData(mProject.FileData);
 }
Esempio n. 3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public ScriptManager(DisasmProject proj)
        {
            mProject = proj;

            if (!proj.UseMainAppDomainForPlugins)
            {
                DomainManager = new DomainManager(UseKeepAliveHack);
                DomainManager.CreateDomain("Plugin Domain", PluginDllCache.GetPluginDirPath());
                DomainManager.PluginMgr.SetFileData(proj.FileData);
            }
            else
            {
                mActivePlugins = new Dictionary <string, IPlugin>();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Attempts to load the specified plugin.  If the plugin is already loaded, this
        /// does nothing.  If not, the assembly is loaded and an instance is created.
        /// </summary>
        /// <param name="scriptIdent">Script identifier.</param>
        /// <param name="report">Report with errors and warnings.</param>
        /// <returns>True on success.</returns>
        public bool LoadPlugin(string scriptIdent, out FileLoadReport report)
        {
            // Make sure the most recent version is compiled.
            string dllPath = PluginDllCache.GenerateScriptDll(scriptIdent,
                                                              mProject.ProjectPathName, out report);

            if (dllPath == null)
            {
                return(false);
            }

            if (DomainMgr == null)
            {
                if (mActivePlugins.TryGetValue(scriptIdent, out IPlugin plugin))
                {
                    return(true);
                }
                Assembly asm = Assembly.LoadFile(dllPath);
                plugin = PluginDllCache.ConstructIPlugin(asm);
                mActivePlugins.Add(scriptIdent, plugin);
                report = new FileLoadReport(dllPath);       // empty report
                return(true);
            }
            else
            {
                CheckHealth();
                IPlugin plugin = DomainMgr.PluginMgr.LoadPlugin(dllPath, scriptIdent,
                                                                out string failMsg);
                if (plugin == null)
                {
                    report.Add(FileLoadItem.Type.Error, "Failed loading plugin: " + failMsg);
                }
                else
                {
                    mLoadedPlugins.Add(new LoadedPluginPath(scriptIdent, dllPath));
                }
                return(plugin != null);
            }
        }