/// <summary>Creates a new <see cref="StartingLineup"/>.</summary>
 /// <param name="league">The league the starting lineup is for.</param>
 /// <param name="date">The date of the lineup.</param>
 /// <param name="positions">The positions available in the lineup.</param>
 /// <param name="assignments">Assignments of players to positions.</param>
 public StartingLineup(League league, DateTime date, IEnumerable<Position> positions, IEnumerable<StartingLineupAssignment> assignments = null)
 {
     this.League = league;
     this.Date = date;
     this.startingPositions.AddRange(positions);
     this.assignments.CollectionChanging += new EventHandler<NotifyCollectionChangingEventArgs>(assignments_CollectionChanging);
     if (assignments != null) { this.assignments.AddRange(assignments); }
 }
Пример #2
0
        /// <summary>Creates a <see cref="Team"/>.</summary>
        /// <param name="league">The league the team is a member of.</param>
        /// <param name="name">The name of the team.</param>
        /// <param name="players">Players on the team.</param>
        public Team(string name, League league = null, IEnumerable<Player> players = null)
        {
            if (string.IsNullOrEmpty(name)) { throw new ArgumentException("name cannot be null or empty", "name"); }

            this.League = league;
            this.Name = name;
            if (players != null) { this.players.AddRange(players); }
        }
 private static Team resolveTeam(League league, string teamName)
 {
     Team team;
     if (league.Teams.Contains(teamName))
     {
         team = league.Teams[teamName];
     }
     else
     {
         team = new Team(teamName, league);
         league.Teams.Add(team);
     }
     return team;
 }
        /// <summary>Creates a new league from data.</summary>
        /// <param name="data">The data file to initialize the league with.</param>
        /// <returns>Returns a new league, initialized with the data.</returns>
        private static League loadCsvData(string data)
        {
            League league = new League();
            bool firstLine = true;
            foreach (string line in data.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (firstLine)
                {
                    firstLine = false;
                    continue;
                }

                string[] parts = line.Split(',');
                DateTime gameDateTime = DateTime.Parse(parts[0] + "," + parts[3]);
                Team visitingTeam = LeagueCsvAdaptor.resolveTeam(league, parts[1].Replace("\"", ""));
                Team homeTeam = LeagueCsvAdaptor.resolveTeam(league, parts[2].Replace("\"", ""));
                Game game = new Game(homeTeam, visitingTeam, gameDateTime);

                league.Games.Add(game);
            }
            return league;
        }
 public static void Setup()
 {
     //MemoryStream stream = new MemoryStream(Properties.Resources.NHLSchedule2010);
     //League league = LeagueCsvAdaptor.LoadCsv(stream);
     SportsModelTests.league = new League();
 }