Пример #1
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
            {
                IPlugin plugin = DomainMgr.PluginMgr.LoadPlugin(dllPath, scriptIdent);
                return(plugin != null);
            }
        }
Пример #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public ScriptManager(DisasmProject proj)
        {
            mProject = proj;

            if (!proj.UseMainAppDomainForPlugins)
            {
                DomainMgr = new DomainManager(UseKeepAliveHack);
                DomainMgr.CreateDomain("Plugin Domain", PluginDllCache.GetPluginDirPath());
                DomainMgr.PluginMgr.SetFileData(proj.FileData);
            }
            else
            {
                mActivePlugins = new Dictionary <string, IPlugin>();
            }
        }