/// <summary> /// Checks for the updated information for the given mod. /// </summary> /// <param name="mod">The mod for which to check for updates.</param> /// <returns>The latest information available for the given mod, /// or <c>null</c> if no information is available.</returns> private IModInfo CheckForUpdate(IMod mod) { IModInfo modInfo = null; if (!ModRepository.IsOffline) { //get mod info for (var i = 0; i <= 2; i++) { if (!string.IsNullOrEmpty(mod.Id)) { modInfo = ModRepository.GetModInfo(mod.Id); } if (modInfo == null) { modInfo = ModRepository.GetModInfoForFile(mod.Filename); } if (modInfo != null) { break; } Thread.Sleep(1000); } } return(modInfo); }
/// <summary> /// Checks for the updated information for the given mod. /// </summary> /// <param name="p_modMod">The mod for which to check for updates.</param> /// <returns>The lastest informaiton available for the given mod, /// or <c>null</c> if no information is available.</returns> private IModInfo CheckForUpdate(IMod p_modMod) { IModInfo mifInfo = null; try { if (!ModRepository.IsOffline) { //get mod info for (int i = 0; i <= 2; i++) { if (!String.IsNullOrEmpty(p_modMod.Id)) { mifInfo = ModRepository.GetModInfo(p_modMod.Id); } if (mifInfo == null) { mifInfo = ModRepository.GetModInfoForFile(p_modMod.Filename); } if (mifInfo != null) { break; } Thread.Sleep(1000); } if (mifInfo == null) { string strSearchTerms = p_modMod.ModName; if (String.IsNullOrEmpty(strSearchTerms)) { strSearchTerms = Path.GetFileNameWithoutExtension(p_modMod.Filename).Replace("_", " ").Replace("-", " "); } //use heuristics to find info if (!String.IsNullOrEmpty(strSearchTerms)) { string[] strTerms = strSearchTerms.Split(' ', '-', '_'); string strSearchString = strTerms.OrderByDescending(s => s.Length).FirstOrDefault(); string strAuthor = p_modMod.Author; if (!String.IsNullOrEmpty(strSearchString) && !String.IsNullOrEmpty(strAuthor) && (strAuthor.Length >= 3)) { mifInfo = ModRepository.FindMods(strSearchString, strAuthor, true).FirstOrDefault(); } } } } if (mifInfo == null) { return(null); } return(mifInfo); } catch (RepositoryUnavailableException) { //the repository is not available, so don't bother return(null); } }