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(); }
void Init(int players, int wins) { _TeamLength = players; _WinLength = wins; _Couples = new List <ICouple>(); for (int i = 0; i < _TeamLength; i++) { ICouple couple = new Couple(Team1.Players[i], Team2.Players[i]); StartGameHandler += couple.StartEvent; Couples.Add(couple); } TaskPool = new List <Task>(); CancelTokenSource = new CancellationTokenSource(); Token = CancelTokenSource.Token; }