Exemplo n.º 1
0
        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;
                }
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 public bool IsAgentIsolated(string agent)
 {
     return(IsolatedAgents.ContainsKey(agent));
 }