Пример #1
0
        /// <summary>
        /// Loads the WDSF couples from a local file
        /// </summary>
        /// <param name="filename">Filename of file to load</param>
        public void LoadWDSFCouples(string filename)
        {
            var doc = new System.Xml.XmlDocument();

            doc.Load(filename);
            DateTime date;

            if (!DateTime.TryParse(doc["Couples"].Attributes["date"].Value, out date))
            {
                DownloadDate = new DateTime(2000, 1, 1, 0, 0, 0, 0);
            }
            else
            {
                DownloadDate = date;
            }

            var list = doc.GetElementsByTagName("Couple");

            foreach (var node in list)
            {
                var c = new Couple();
                c.FromXml((System.Xml.XmlNode)node);
                this.WDSF_Couples.Add(c);
                this.Persons.Add(c.Man);
                this.Persons.Add(c.Woman);
            }
        }
Пример #2
0
        public void LoadParticipants(string file)
        {
            System.IO.StreamReader sr = null;

            try
            {
                sr = new System.IO.StreamReader(file, System.Text.Encoding.UTF8);
            }
            catch (Exception)
            {
                return;
            }
            while (!sr.EndOfStream)
            {
                var line = sr.ReadLine();
                try
                {
                    var data = line.Split(';');
                    if (data.Length < 12)
                    {
                        data = line.Split(','); // Try to split comma
                    }
                    // Do we have this couple?
                    var c = Couples.FirstOrDefault(co => co.Man.FirstName == data[4] &&
                                                   co.Man.LastName == data[5] &&
                                                   co.Woman.FirstName == data[6] &&
                                                   co.Woman.LastName == data[7]
                                                   );
                    if (c == null)
                    {
                        c     = new Couple();
                        c.Man = new Person()
                        {
                            FirstName = data[4], LastName = data[5], Country = data[8]
                        };
                        c.Woman = new Person()
                        {
                            FirstName = data[6], LastName = data[7], Country = data[8]
                        };
                        Couples.Add(c);
                    }
                    // Add the competition to your competition list
                    c.AddParticipation(data[0], data[11]);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("mal-formed participant file in line " + line);
                }
            }

            sr.Close();
        }
Пример #3
0
        /// <summary>
        /// Implementation of equal to compare two couples
        /// </summary>
        /// <param name="obj">the couple to compare</param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            Couple comp = (Couple)obj;

            // we compare the names, this is the only way to make sure
            // it's the same. Won't work with spelling mistakes
            return(comp.Man.FirstName == this.Man.FirstName &&
                   comp.Man.LastName == this.Man.LastName &&
                   comp.Woman.FirstName == this.Woman.FirstName &&
                   comp.Woman.LastName == this.Woman.LastName);
        }