示例#1
0
        private void OnInstallAddons(object sender, EventArgs e)
        {
            OPMOpenFileDialog dlg = new OPMOpenFileDialog();

            dlg.Filter = Translator.Translate("TXT_INSTALLADDONFILTER");
            dlg.Title  = Translator.Translate("TXT_INSTALLADDONS");

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if (dlg.FileName.ToLowerInvariant().Contains("builtin"))
                    {
                        ErrorDispatcher.DispatchError(Translator.Translate("TXT_CANT_INSTALL_BUILTIN"), false);
                    }
                    else if (!dlg.FileName.ToLowerInvariant().EndsWith("extension.dll"))
                    {
                        ErrorDispatcher.DispatchError(Translator.Translate("TXT_INVALID_NAME"), false);
                    }
                    else if (TestAssembly(dlg.FileName))
                    {
                        AddonsConfig.InstallAddonLibrary(dlg.FileName);
                        ReloadConfig();
                    }
                    else
                    {
                        ErrorDispatcher.DispatchError(Translator.Translate("TXT_INVALID_ADDON"), false);
                    }
                }
                catch (Exception ex)
                {
                    ErrorDispatcher.DispatchError(ex, false);
                }
            }
        }
示例#2
0
        private AddonInfo ConstructAddonInfo(string addon)
        {
            string detectedCodebase   = AddonDetector.GetAssemblyInfo(addon);
            string configuredCodebase = AddonsConfig.GetAssemblyInfo(addon);
            bool   selected           = (detectedCodebase == configuredCodebase);
            bool   isRequired         = AddonDetector.IsRequiredAddon(addon);

            return(new AddonInfo(addon, detectedCodebase, selected, isRequired));
        }
        /// <summary>
        /// Private contructor.
        /// The class is a singleton.
        /// </summary>
        private AddonsCore()
        {
            Translator.RegisterTranslationAssembly(GetType().Assembly);

            Logger.LogTrace("Checking default addons configuration ...");

            // Init addons config first
            AddonsConfig.Init();
            InitializeAddons();
        }
示例#4
0
        private void ScheduleForUninstall(string assembly)
        {
            string addons = string.Empty;

            List <AddonInfo> itemsToDisable = new List <AddonInfo>();

            foreach (AddonInfo ai in addonList.AllAddons)
            {
                string[] codebaseParts = ai.CodeBase.Split(new char[] { '|' });
                if (codebaseParts.Length > 0 &&
                    codebaseParts[0].ToLowerInvariant() == assembly.ToLowerInvariant())
                {
                    addons += ai.TranslatedName;
                    addons += "\n";
                    itemsToDisable.Add(ai);
                }
            }

            if (itemsToDisable.Count < 1)
            {
                return;
            }

            if (itemsToDisable.Count == 1 ||
                (MessageDisplay.Query(Translator.Translate("TXT_SHAREDADDONS", addons),
                                      Translator.Translate("TXT_CAUTION"), MessageBoxIcon.Question) == DialogResult.Yes))
            {
                // Clear for uninstalling.

                foreach (AddonInfo ai in itemsToDisable)
                {
                    PersistenceProxy.DeleteObject(ai.Name, false);
                    addonList.RemoveAddon(ai);
                }

                AddonsConfig.MarkForUninstall(assembly);
                _uninstallScheduled = true;
            }
        }