protected override string Prefetch(long id) { string name = null; if (id < int.MaxValue && id > int.MinValue && id != 0) { int intId = (int)id; // Check NPC corporations var npcCorp = StaticGeography.GetCorporationByID(intId); if (npcCorp != null) { name = npcCorp.Name; } else { // Check NPC factions var npcFaction = StaticGeography.GetFactionByID(intId); if (npcFaction != null) { name = npcFaction.Name; } } } return(name); }
protected override string Prefetch(long id) { string name = null; if (id == 0L) { // Empty IDs are always "unknown" name = EveMonConstants.UnknownText; } else if (id < int.MaxValue && id > int.MinValue) { int intId = (int)id; // Check NPC corporations var npcCorp = StaticGeography.GetCorporationByID(intId); if (npcCorp != null) { name = npcCorp.Name; } else { // Check NPC factions var npcFaction = StaticGeography.GetFactionByID(intId); if (npcFaction != null) { name = npcFaction.Name; } } } // Try filling with a current character identity or corporation/alliance if (string.IsNullOrEmpty(name)) { foreach (var character in EveMonClient.Characters) { string corpName = character.CorporationName, allianceName = character. AllianceName; if (character.CharacterID == id) { name = character.Name; break; } if (character.CorporationID == id && !corpName.IsEmptyOrUnknown()) { name = corpName; break; } if (character.AllianceID == id && !allianceName.IsEmptyOrUnknown()) { name = allianceName; break; } } } return(name); }
/// <summary> /// Gets the corporation name from the provided ID. /// </summary> /// <param name="id">The id.</param> /// <returns></returns> private static string GetIDToName(long id) { string corporationName = String.Empty; // Check if it's an NPC Corporation if (id <= Int32.MaxValue) { NPCCorporation corporation = StaticGeography.GetCorporationByID((int)id); corporationName = corporation?.Name ?? String.Empty; } // If it's a player's corporation, query the API return(string.IsNullOrEmpty(corporationName) ? EveIDToName.GetIDToName(id) : corporationName); }
/// <summary> /// Gets the corporation name from the provided ID. /// </summary> /// <param name="id">The id.</param> /// <returns></returns> private static string GetIDToName(long id) { string corporationName = String.Empty; // Check if it's an NPC Corporation if (id > Int32.MaxValue) { return(String.IsNullOrEmpty(corporationName) ? EveIDToName.GetIDToName(id) : corporationName); } int npcCorpID = Convert.ToInt32(id); NPCCorporation corporation = StaticGeography.GetCorporationByID(npcCorpID); corporationName = corporation?.Name ?? String.Empty; // If it's a player's corporation, query the API return(String.IsNullOrEmpty(corporationName) ? EveIDToName.GetIDToName(id) : corporationName); }