/// <summary> /// Activates the given mod. /// </summary> /// <remarks> /// The given mod is either installed or upgraded, as appropriate. /// </remarks> /// <param name="p_modMod">The mod to install.</param> /// <param name="p_dlgUpgradeConfirmationDelegate">The delegate that is called to confirm whether an upgrade install should be performed.</param> /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param> /// <param name="p_rolActiveMods">The list of active mods.</param> /// <returns>A background task set allowing the caller to track the progress of the operation.</returns> public IBackgroundTaskSet Activate(IMod p_modMod, ConfirmModUpgradeDelegate p_dlgUpgradeConfirmationDelegate, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList <IMod> p_rolActiveMods, bool p_booOverrideUpgrade) { ModMatcher mmcMatcher = new ModMatcher(InstallationLog.ActiveMods, true); IMod modOldVersion = mmcMatcher.FindAlternateVersion(p_modMod, true); ConfirmUpgradeResult curAction = ConfirmUpgradeResult.NormalActivation; if (!p_booOverrideUpgrade) { curAction = (modOldVersion == null) ? ConfirmUpgradeResult.NormalActivation : p_dlgUpgradeConfirmationDelegate(modOldVersion, p_modMod); } switch (curAction) { case ConfirmUpgradeResult.Upgrade: ModInstaller muiUpgrader = InstallerFactory.CreateUpgradeInstaller(modOldVersion, p_modMod, p_dlgOverwriteConfirmationDelegate); return(muiUpgrader); case ConfirmUpgradeResult.NormalActivation: ModInstaller minInstaller = InstallerFactory.CreateInstaller(p_modMod, p_dlgOverwriteConfirmationDelegate, p_rolActiveMods); return(minInstaller); case ConfirmUpgradeResult.Cancel: return(null); default: throw new Exception(String.Format("Unrecognized value for ConfirmUpgradeResult: {0}", curAction)); } }
/// <summary> /// Activates the given mod. /// </summary> /// <param name="p_modMod">The mod to activate.</param> /// <param name="p_dlgUpgradeConfirmationDelegate">The delegate that is called to confirm whether an upgrade install should be performed.</param> /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param> /// <param name="p_rolActiveMods">The list or Active mods.</param> /// <returns>A background task set allowing the caller to track the progress of the operation.</returns> public IBackgroundTaskSet ActivateMod(IMod p_modMod, ConfirmModUpgradeDelegate p_dlgUpgradeConfirmationDelegate, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList <IMod> p_rolActiveMods) { if (InstallationLog.ActiveMods.Contains(p_modMod)) { return(null); } return(Activator.Activate(p_modMod, p_dlgUpgradeConfirmationDelegate, p_dlgOverwriteConfirmationDelegate, p_rolActiveMods)); }
/// <summary> /// Activates the given mod. /// </summary> /// <remarks> /// The given mod is either installed or upgraded, as appropriate. /// </remarks> /// <param name="p_modMod">The mod to install.</param> /// <param name="p_dlgUpgradeConfirmationDelegate">The delegate that is called to confirm whether an upgrade install should be performed.</param> /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param> /// <param name="p_rolActiveMods">The list of active mods.</param> /// <returns>A background task set allowing the caller to track the progress of the operation.</returns> public IBackgroundTaskSet Activate(IMod p_modMod, ConfirmModUpgradeDelegate p_dlgUpgradeConfirmationDelegate, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList<IMod> p_rolActiveMods) { ModMatcher mmcMatcher = new ModMatcher(InstallationLog.ActiveMods, true); IMod modOldVersion = mmcMatcher.FindAlternateVersion(p_modMod, true); ConfirmUpgradeResult curAction = (modOldVersion == null) ? ConfirmUpgradeResult.NormalActivation : p_dlgUpgradeConfirmationDelegate(modOldVersion, p_modMod); switch (curAction) { case ConfirmUpgradeResult.Upgrade: ModInstaller muiUpgrader = InstallerFactory.CreateUpgradeInstaller(modOldVersion, p_modMod, p_dlgOverwriteConfirmationDelegate); return muiUpgrader; case ConfirmUpgradeResult.NormalActivation: ModInstaller minInstaller = InstallerFactory.CreateInstaller(p_modMod, p_dlgOverwriteConfirmationDelegate, p_rolActiveMods); return minInstaller; case ConfirmUpgradeResult.Cancel: return null; default: throw new Exception(String.Format("Unrecognized value for ConfirmUpgradeResult: {0}", curAction)); } }
/// <summary> /// Reinstalls the given mod. /// </summary> /// <param name="p_modMod">The mod to reinstall.</param> /// <param name="p_dlgUpgradeConfirmationDelegate">The delegate that is called to confirm whether an upgrade install should be performed.</param> /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param> /// <param name="p_rolActiveMods">The list or Active mods.</param> /// <returns>A background task set allowing the caller to track the progress of the operation.</returns> public IBackgroundTaskSet ReinstallMod(IMod p_modMod, ConfirmModUpgradeDelegate p_dlgUpgradeConfirmationDelegate, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList <IMod> p_rolActiveMods) { DeleteXMLInstalledFile(p_modMod); return(Activator.Activate(p_modMod, p_dlgUpgradeConfirmationDelegate, p_dlgOverwriteConfirmationDelegate, p_rolActiveMods, true)); }
/// <summary> /// Activates the given mod. /// </summary> /// <param name="p_modMod">The mod to activate.</param> /// <param name="p_dlgUpgradeConfirmationDelegate">The delegate that is called to confirm whether an upgrade install should be performed.</param> /// <param name="p_dlgOverwriteConfirmationDelegate">The method to call in order to confirm an overwrite.</param> /// <param name="p_rolActiveMods">The list or Active mods.</param> /// <returns>A background task set allowing the caller to track the progress of the operation.</returns> public IBackgroundTaskSet ActivateMod(IMod p_modMod, ConfirmModUpgradeDelegate p_dlgUpgradeConfirmationDelegate, ConfirmItemOverwriteDelegate p_dlgOverwriteConfirmationDelegate, ReadOnlyObservableList<IMod> p_rolActiveMods) { if (InstallationLog.ActiveMods.Contains(p_modMod)) return null; DeleteXMLInstalledFile(p_modMod); return Activator.Activate(p_modMod, p_dlgUpgradeConfirmationDelegate, p_dlgOverwriteConfirmationDelegate, p_rolActiveMods); }