예제 #1
0
        public static bool ValidCountry(String country)
        {
            if ("|us|ut|ca|".IndexOf("|" + country.ToLower() + "|") > -1)
            {
                return(true);
            }

            return(Countries.Contains(country.ToLower()));
        }
예제 #2
0
        public void UpdateInfos(IList <Country> countries, string officialUrl, DateTime lastUpdate, Reviewer reviewer, IList <string> similarArtists)
        {
            #region parameters validation

            if (reviewer == null)
            {
                throw new ArgumentException("Artist update : 'reviewer' cannot be null nor empty");
            }
            if (lastUpdate == DateTime.MinValue)
            {
                throw new ArgumentException("Artist update : 'lastUpdate' must be a valid date");
            }

            #endregion

            //if older version than the current one, return without doing anything
            if (lastUpdate < LastUpdate)
            {
                return;
            }

            foreach (var country in countries)
            {
                if (!Countries.Contains(country))
                {
                    Countries.Add(country);
                }
            }

            LastUpdate = lastUpdate;
            Reviewer   = reviewer;

            if (!string.IsNullOrEmpty(officialUrl))
            {
                OfficialUrl = officialUrl;
            }

            //Add new similar artists, avoiding duplicates
            foreach (var similarArtist in similarArtists)
            {
                if (!RawSimilarArtists.Contains(similarArtist) && similarArtist != Name)
                {
                    RawSimilarArtists.Add(similarArtist);
                }
            }
        }
예제 #3
0
        private async Task <bool> CheckCountry(IServiceProvider services)
        {
            if (Countries != null && Countries.Any())
            {
                var locationInfo = await GetGeoLocation(services);

                if (locationInfo == null)
                {
                    return(Countries.Contains("unknown"));
                }
                else
                {
                    return(Countries.Contains(locationInfo.CountryCode));
                }
            }

            return(true);
        }
예제 #4
0
        public new void Add(Movie item)
        {
            if (!String.IsNullOrEmpty(item.Category) && !Categories.Contains(item.Category))
            {
                Categories.Add(item.Category);
            }

            if (!String.IsNullOrEmpty(item.Country) && !Countries.Contains(item.Country))
            {
                Countries.Add(item.Country);
            }

            if (item.Actors != null)
            {
                foreach (string actor in item.Actors)
                {
                    if (!Actors.Contains(actor.Trim()))
                    {
                        Actors.Add(actor.Trim());
                    }
                }
            }

            if (item.ID == 0 || usedIds.Contains(item.ID))
            {
                item.ID = idCounter;
                idCounter++;
            }
            else
            {
                usedIds.Add(item.ID);
                idCounter = item.ID + 1;
            }

            base.Add(item);
        }
예제 #5
0
        public static void Load()
        {
            //TODO MUST making the xml called data.dat and encryption
            if (File.Exists("Data.dat"))
            {
                using (XmlReader reader = XmlReader.Create("Data.dat"))
                {
                    Countries.Clear();
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            if (reader.Name == "Data")
                            {
                                FirstRun          = bool.Parse(reader.GetAttribute("FirstRun"));
                                CurrentMacAddress = reader.GetAttribute("MacAddress");
                                CommitteeName     = reader.GetAttribute("CommitteeName");
                                GSLAgenda         = reader.GetAttribute("GSLAgenda");
                                SSLAgenda         = reader.GetAttribute("SSLAgenda");
                                RollCallDone      = bool.Parse(reader.GetAttribute("RollCallDone"));
                                ExtraData         = reader.GetAttribute("ExtraData");
                            }
                            else if (reader.Name == "Country")
                            {
                                Country country = new Country();
                                country.Name = reader.GetAttribute("Name");
                                country.Flag = reader.GetAttribute("Flag");
                                switch (reader.GetAttribute("Attendance"))
                                {
                                case "PresentAndVoting":
                                    country.Attendance = Attendance.PresentAndVoting;
                                    break;

                                case "Present":
                                    country.Attendance = Attendance.Present;
                                    break;

                                default:
                                case "Absent":
                                    country.Attendance = Attendance.Absent;
                                    break;
                                }
                                country.GSL = int.Parse(reader.GetAttribute("GSL"));
                                country.SSL = int.Parse(reader.GetAttribute("SSL"));
                                if (!Countries.Contains(country))
                                {
                                    Countries.Add(country);
                                }
                            }
                            else if (reader.Name == "Topics")
                            {
                                using (XmlReader topicsReader = reader.ReadSubtree())
                                {
                                    while (topicsReader.Read())
                                    {
                                        if (topicsReader.NodeType == XmlNodeType.Element && topicsReader.Name == "Topic")
                                        {
                                            Topic topic = new Topic();
                                            topic.Heading    = topicsReader.GetAttribute("Heading");
                                            topic.Passed     = bool.Parse(topicsReader.GetAttribute("Passed"));
                                            topic.ProposedBy = FindCountry(topicsReader.GetAttribute("ProposedBy"));
                                            using (XmlReader speakersReader = topicsReader.ReadSubtree())
                                            {
                                                while (speakersReader.Read())
                                                {
                                                    if (speakersReader.NodeType == XmlNodeType.Element && speakersReader.Name == "Country")
                                                    {
                                                        topic.SpeakingCountries.Add(FindCountry(speakersReader.ReadElementContentAsString()));
                                                    }
                                                }
                                            }
                                            if (!topic.ProposedBy.MC.Contains(topic))
                                            {
                                                topic.ProposedBy.MC.Add(topic);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                FirstRun          = true;
                CurrentMacAddress = string.Empty;
                Countries         = GetDefaultCountries();
                CommitteeName     = "Committee";
                GSLAgenda         = "GSL Agenda";
                SSLAgenda         = "SSL Agenda";
                RollCallDone      = false;
                ExtraData         = string.Empty;
            }
        }
 public bool Contains(Country item) => Countries.Contains(item);