Exemple #1
0
        // NOTE: Metodi Equals i GetHashCode su mi trebali prilikom parsiranja
        // fajla sa rasporedom sudija (sudije sam stavljao u ISet, a on
        // zahteva ove metode)
        public override bool Equals(object other)
        {
            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }
            if (!(other is Sudija))
            {
                return(false);
            }
            Sudija that = (Sudija)other;

            return(this.Ime.ToUpper() == that.Ime.ToUpper() &&
                   this.Prezime.ToUpper() == that.Prezime.ToUpper());
        }
        private void insertSudije()
        {
            IList<Drzava> drzave = dataContext.GetAll<Drzava>();
            ISet<Sudija> sudije = new HashSet<Sudija>();

            string[] fileNames = new string[]
                {
                    @"..\..\test\Data\RasporedSudijaMuskarciKvalifikacije.txt",
                    @"..\..\test\Data\RasporedSudijaMuskarciViseboj.txt",
                    @"..\..\test\Data\RasporedSudijaZeneKvalifikacije.txt",
                    @"..\..\test\Data\RasporedSudijaZeneViseboj.txt"
                };

            for (int i = 0; i < fileNames.Length; i++)
            {
                SudijeParser parser = new SudijeParser();
                parser.parse(fileNames[i]);

                Pol pol = Pol.Muski;
                if (i > 1)
                    pol = Pol.Zenski;
                foreach (object[] o in parser.SudijskeUloge)
                {
                    string ime = (string)o[0];
                    string prezime = (string)o[1];
                    string kod = (string)o[2];

                    Sudija sudija = new Sudija();
                    sudija.Ime = ime;
                    sudija.Prezime = prezime;
                    sudija.Pol = pol;
                    sudija.Drzava = findDrzava(kod, drzave);
                    sudije.Add(sudija);
                }
            }

            foreach (Sudija s in sudije)
                dataContext.Add(s);
        }