public void LoadEntities(List <MissionEntity> entities) { MissionsList.AddRange(entities); IsolatedAgents.Clear(); IsolationsPerCountry.Clear(); MostIsolatedCountry = null; foreach (var entity in entities) { ParseEntity(entity); } // Calculate IsolationsPerCountry foreach ((string agent, string country) in IsolatedAgents) { if (!IsolationsPerCountry.ContainsKey(country)) { IsolationsPerCountry.Add(country, 0); } IsolationsPerCountry[country]++; if (string.IsNullOrWhiteSpace(MostIsolatedCountry) || IsolationsPerCountry[country] > IsolationsPerCountry[MostIsolatedCountry]) { MostIsolatedCountry = country; } } }
private void ParseEntity(MissionEntity entity) { if (NonIsolatedAgents.Contains(entity.Agent)) { return; } if (!IsolatedAgents.ContainsKey(entity.Agent)) { IsolatedAgents.Add(entity.Agent, entity.Country); } else { IsolatedAgents.Remove(entity.Agent); NonIsolatedAgents.Add(entity.Agent); } }
public bool IsAgentIsolated(string agent) { return(IsolatedAgents.ContainsKey(agent)); }