public GsTeam(DataRow teamRow, string leagueId, ILeague league) { LeagueId = leagueId; League = league; _teamHt = new Hashtable(); Name = teamRow["FRANCHISE"].ToString().Trim(); OwnerId = teamRow["OWNERID"].ToString().Trim(); _playerList = new ArrayList(); for (var i = 65; i < 91; i++) // from A-Z { var playerCode = string.Format("PLAYER{0}", (char)i); AddPlayer(teamRow[playerCode].ToString().Trim()); } //PrintIndexAndKeysAndValues( teamHT ); FigureOutGreatestBias(); IsHuman = FigureOutHumanity(); #if DEBUG Utility.Announce(string.Format("{0,-20} has {1} PlayoffStarters {2} PlayoffBackups {3} PlayoffOthers", TeamOut(), PlayoffStarters, PlayoffBackups, PlayoffOthers)); #endif }
private async void LeagueRaceCombo_TextUpdate(object sender, EventArgs e) { ComboBox cb = (ComboBox)sender; int startLength = cb.Text.Length; await Task.Delay(Properties.Settings.Default.TextChangedDelay).ConfigureAwait(true); if (startLength == cb.Text.Length) { var leagueId = cb.Text; logger.Debug($"Get league {leagueId}"); var league = await httpClientService.GetLeagueAsync(leagueId).ConfigureAwait(true); if (league == null) { errorProvider.SetError(leagueRaceCombo, Strings.FailedToRetrieveLeague); } else { selectedLeague = league; leagueUrlLink.Enabled = false; errorProvider.SetError(leagueRaceCombo, ""); Properties.Settings.Default.LeagueId = selectedLeague.Id; } InitializeCharactersList(); } }
private ITeam CreateNewTeamAndAddToList(ILeague league, string nameOfNewTeam) { var team = _svc.CreateNewTeamInLeague(league, nameOfNewTeam); _createdTeams.Add(team); return(team); }
public IReadOnlyList <ILeagueMatch> FindAll(ILeague league) { const string sql = @" SELECT league_match_id as leaguematchid, league_id as leagueid, home_match_team_id as homematchleagueteamid, away_match_team_id as awaymatchleagueteamid, match_created_time as matchcreatedtime, match_start_time as matchstarttime, match_finish_time as matchfinishtime, match_results as matchesults, match_results_reported_time as matchesultsreportedtime FROM public.league_match WHERE league_id = @LeagueId" ; using (var connection = AppDataConnection.Create()) { var records = connection.Query <LeagueMatchRecord>(sql, new { league.LeagueId }).ToList(); var leagueTeamIds = records.SelectMany(x => new[] { x.AwayLeagueTeamId, x.HomeLeagueTeamId }).ToList(); var leagueTeamsByLeagueTeamId = new LeagueTeamStore().Find(leagueTeamIds).ToDictionary(x => x.LeagueTeamId, x => x); return(records.Select(record => Create(record, leagueTeamsByLeagueTeamId)).ToList()); } }
public GsTeam( DataRow teamRow, string leagueId, ILeague league ) { LeagueId = leagueId; League = league; _teamHt = new Hashtable(); Name = teamRow["FRANCHISE"].ToString().Trim(); OwnerId = teamRow["OWNERID"].ToString().Trim(); _playerList = new ArrayList(); for (var i = 65; i < 91; i++ ) // from A-Z { var playerCode = string.Format( "PLAYER{0}", (char) i ); AddPlayer( teamRow[ playerCode ].ToString().Trim() ); } //PrintIndexAndKeysAndValues( teamHT ); FigureOutGreatestBias(); IsHuman = FigureOutHumanity(); #if DEBUG Utility.Announce( string.Format( "{0,-20} has {1} PlayoffStarters {2} PlayoffBackups {3} PlayoffOthers", TeamOut(), PlayoffStarters, PlayoffBackups, PlayoffOthers ) ); #endif }
public DashboardController(IFranchise franchises, IPlayer player, ILeague leagues, UserManager <ApplicationUser> userManager) { _franchises = franchises; _leagues = leagues; _userManager = userManager; _players = player; }
public App(ILeague initialLeague, ILeagueRenderer leagueRenderer, IFileService fileService) { _league = initialLeague; _leagueRenderer = leagueRenderer; _fileService = fileService; _autosaveName = GenerateAutoSaveName(); }
public ILeague GetGenericLeague() { ILeague league = null; string leagueName = "Quick Play"; using (var context = new Data.DartballContext()) { var item = context.Leagues.FirstOrDefault(x => x.Name == leagueName); if (item == null) { LeagueDto dto = new LeagueDto() { Name = leagueName, Password = "******" }; AddNew(dto); item = context.Leagues.FirstOrDefault(x => x.Name == leagueName); league = Mapper.Map <LeagueDto>(item); } else { league = Mapper.Map <LeagueDto>(item); } } return(league); }
public LeagueViewModel CreateDetailedViewModel(ILeague league) { return(new LeagueViewModel { LeagueId = league.LeagueId, Name = league.Name, }); }
public LeaguesController(ApplicationDbContext db, IConfiguration configuration, IUpload uploadService, ILeague leagueService, IHostingEnvironment environment) { _db = db; _leagueService = leagueService; _uploadService = uploadService; _configuration = configuration; _environment = environment; }
public void Setup() { this.LeagueDataFile = TestContext.DataRow["LeagueDataFile"].ToString(); this.StatsDataFile = TestContext.DataRow["StatsDataFile"].ToString(); this.NFL = new LeagueBuilder(TestContext).BuildNFLLeague(this.StatsDataFile, this.LeagueDataFile, 17); Console.WriteLine($"Author: {TestContext.DataRow["Author"].ToString()}"); Console.WriteLine($"Assembly: {TestContext.DataRow["Assembly"].ToString()}"); Console.WriteLine($"LeagueFile: {TestContext.DataRow["LeagueDataFile"].ToString()}"); Console.WriteLine($"StatsFile: {TestContext.DataRow["StatsDataFile"].ToString()}"); }
public void Save(string path, ILeague league) { try { File.WriteAllLines(path, league.GetRows().Select(SerialiseRow)); } catch (IOException e) { throw new ArgumentException($"Could not save league {path}", e); } }
public void Initilize() { string[] existingGameFiles = { "existingGame" }; _fileServiceMock = new Mock <IFileService>(); _fileServiceMock.Setup(f => f.Load("existingGame")).Returns(new League()); _fileServiceMock.Setup(f => f.Load(It.IsNotIn <string>(existingGameFiles))).Throws(new ArgumentException()); _league = new League(); ILeagueRenderer leagueRenderer = new LeagueRenderer(); IFileService fileService = _fileServiceMock.Object; _app = new App(_league, leagueRenderer, fileService); }
ITeam ILeagueOperator.CreateNewTeamInLeague(ILeague leagueToCreateNewTeamIn, string nameOfNewTeam) { var newTeam = Teambuilder(); newTeam.Name = nameOfNewTeam; if (!teams.TryAdd(nameOfNewTeam, newTeam)) { throw new InvalidOperationException(Strings.TeamWithNameAlreadyExists); } return(newTeam); }
public string Render(ILeague league) { var rows = league.GetRows(); if (rows.Count == 0) { return("No players yet"); } var renderedRows = rows.Select((row, index) => RenderRow(row, index, rows.Count)); return(string.Join("\r\n", renderedRows)); }
public TeamsController(ApplicationDbContext db, IConfiguration configuration, IUpload uploadService, ILeague leagueService, ITeam teamService, IHostingEnvironment environment, IManager managerService, IStadium stadiumService, IPlayer playerService) { _db = db; _leagueService = leagueService; _uploadService = uploadService; _configuration = configuration; _teamService = teamService; _environment = environment; _managerService = managerService; _stadiumService = stadiumService; _playerService = playerService; }
public void Initilize() { var leagueMock = new Mock <ILeague>(); var leagueRendererMock = new Mock <ILeagueRenderer>(); var fileServiceMock = new Mock <IFileService>(); string[] namesTaken = { "test", "test$1" }; fileServiceMock.Setup(f => f.Load(It.IsIn(namesTaken))).Returns(new League()); fileServiceMock.Setup(f => f.Load(It.IsNotIn(namesTaken))).Throws(new ArgumentException()); league = leagueMock.Object; _leagueRenderer = leagueRendererMock.Object; _fileService = fileServiceMock.Object; }
private void LeagueRaceCombo_SelectedIndexChanged(object sender, EventArgs e) { ComboBox comboBox = (ComboBox)sender; ComboBoxItem item = comboBox.SelectedItem as ComboBoxItem; selectedLeague = item.Value as League; Properties.Settings.Default.LeagueId = selectedLeague.Id; leagueUrlLink.Enabled = true; InitializeCharactersList(); DisplayLeagueInfo(); }
public ILeague GetLeague(Guid leagueId) { ILeague league = null; using (var context = new Data.DartballContext()) { var item = context.Leagues.FirstOrDefault(x => x.LeagueId == leagueId.ToString()); if (item != null) { league = Mapper.Map <LeagueDto>(item); } } return(league); }
/// <summary> /// Constructs a Riot Client with given implemented service for each Riot service group. /// </summary> /// <param name="champion">The champion.</param> /// <param name="currentGame">The current game.</param> /// <param name="featuredGames">The featured games.</param> /// <param name="game">The game.</param> /// <param name="league">The league.</param> /// <param name="lolStaticData">The lol static data.</param> /// <param name="lolStatus">The lol status.</param> /// <param name="match">The match.</param> /// <param name="matchHistory">The match history.</param> /// <param name="matchList">The match list.</param> /// <param name="stats">The stats.</param> /// <param name="summoner">The summoner.</param> /// <param name="team">The team.</param> public RiotClient(IChampion champion, ICurrentGame currentGame, IFeaturedGames featuredGames, IGame game, ILeague league, ILolStaticData lolStaticData, ILolStatus lolStatus, IMatch match, IMatchHistory matchHistory, IMatchList matchList, IStats stats, ISummoner summoner, ITeam team) { this.Champion = champion; this.CurrentGame = currentGame; this.FeaturedGames = featuredGames; this.Game = game; this.League = league; this.LolStaticData = lolStaticData; this.LolStatus = lolStatus; this.Match = match; this.MatchHistory = matchHistory; this.MatchList = matchList; this.Stats = stats; this.Summoner = summoner; this.Team = team; }
public PredictWrapper(string DLLPath, int year, int week) { _league = new LeagueBuilder(DLLPath).BuildNFLLeague($"{DATA_PATH}NFLStats_{year}.xml", $"{DATA_PATH}NFL_{year}.xml"); _leagueLastWeek = new LeagueBuilder(DLLPath).BuildNFLLeague($"{DATA_PATH}NFLStats_{year}.xml", $"{DATA_PATH}NFL_{year}.xml", (week - 1)); Assembly asm = Assembly.LoadFile(DLLPath); Type predictor = asm.GetType("FootballObjects.Predictor"); try { _predictor = Activator.CreateInstance(predictor, _leagueLastWeek) as IPredictor; } catch (MissingMethodException) { _predictor = Activator.CreateInstance(predictor) as IPredictor; } }
public void Set() { string leagueJson = Encoding.UTF8.GetString(POEToolsTestsBase.Properties.Resources.League);; ILeague league2 = JsonConvert.DeserializeObject <ILeague>(leagueJson, GetJsonSettings()); IEntry entry2 = league.Ladder.Entries[1]; string accountName2 = "morinfa2"; config.League = league2; config.Entry = entry2; config.AccountName = accountName2; config.Culture = CultureInfo.InvariantCulture; Assert.AreEqual(league2, config.League); Assert.AreEqual(entry2, config.Entry); Assert.AreEqual(accountName2, config.AccountName); Assert.AreEqual(CultureInfo.InvariantCulture, config.Culture); }
private bool TryFindLeague(FindLeagueRequest request, out ILeague league) { if (request.LeagueId.HasValue) { league = _leagueStore.Find(request.LeagueId.Value); return(true); } if (!string.IsNullOrEmpty(request.Path)) { league = _leagueStore.FindByPath(request.Path); return(true); } league = null; return(false); }
public DefaultFeedManager(IMessenger messenger, IUrlFetcher urlFetcher, IOptions options, IProxy proxy, IDownloader downloader, ILeague league) { _messenger = messenger; _urlFetcher = urlFetcher; _options = options; _proxy = proxy; _league = league; _downloader = downloader; _startDate = _endDate = (options.Date != null) ? DateTime.Parse(options.Date) : DateTime.Now; _startDate = _startDate.Subtract(new TimeSpan(24 * options.Days, 0, 0)); ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => { return(true); }; }
/// <summary> /// Constructs a Riot Client with given implemented service for each Riot service group. /// </summary> /// <param name="champion">The champion.</param> /// <param name="currentGame">The current game.</param> /// <param name="featuredGames">The featured games.</param> /// <param name="game">The game.</param> /// <param name="league">The league.</param> /// <param name="lolStaticData">The lol static data.</param> /// <param name="lolStatus">The lol status.</param> /// <param name="match">The match.</param> /// <param name="matchHistory">The match history.</param> /// <param name="matchList">The match list.</param> /// <param name="stats">The stats.</param> /// <param name="summoner">The summoner.</param> /// <param name="team">The team.</param> public RiotClient(IChampion champion, ICurrentGame currentGame, IFeaturedGames featuredGames, IGame game, ILeague league, ILolStaticData lolStaticData, ILolStatus lolStatus, IMatch match, IMatchHistory matchHistory, IMatchList matchList, IStats stats, ISummoner summoner, ITeam team) { //we need to let Ninject know which concrete type to use to satisfy the interface. this.Champion = champion; this.CurrentGame = currentGame; this.FeaturedGames = featuredGames; this.Game = game; this.League = league; this.LolStaticData = lolStaticData; this.LolStatus = lolStatus; this.Match = match; this.MatchHistory = matchHistory; this.MatchList = matchList; this.Stats = stats; this.Summoner = summoner; this.Team = team; }
public IReadOnlyList <ILeagueTeam> Find(ILeague league) { const string sql = @" SELECT league_team_id as leagueteamid, team_id as teamid, created_at_time as createdattime, created_by_user_id as createdbyuserid FROM public.league_team WHERE league_id = @LeagueId" ; using (var connection = AppDataConnection.Create()) { var records = connection.Query <LeagueTeamRecord>(sql, new { league.LeagueId }).ToList(); var teamByTeamId = _teamStore.FindTeams(records.Select(x => x.TeamId).ToList()).ToDictionary(x => x.TeamId, x => x); return(records.Select(record => CreateLeagueTeam(record, teamByTeamId[record.TeamId])).ToList()); } }
public void GetLeagueAsync() { var leagueJson = Encoding.UTF8.GetString(POEToolsTestsBase.Properties.Resources.League); string leagueId = "Hardcore"; var url = $"https://api.pathofexile.com/leagues/{leagueId}"; var list = new List <UrlWithResponse>() { new UrlWithResponse() { Url = url, Response = leagueJson, StatusCode = HttpStatusCode.OK, } }; service = GetService(list); ILeague league = service.GetLeagueAsync(leagueId).Result; Assert.AreEqual(leagueId, league.Id); }
private async void SetSelectedLeague() { selectedLeague = null; foreach (var item in leagueRaceCombo.Items) { var league = (item as ComboBoxItem).Value as League; if (league.Id == Properties.Settings.Default.LeagueId) { leagueRaceCombo.SelectedIndexChanged -= LeagueRaceCombo_SelectedIndexChanged; leagueRaceCombo.SelectedItem = item; leagueRaceCombo.SelectedIndexChanged += LeagueRaceCombo_SelectedIndexChanged; selectedLeague = league; leagueUrlLink.Enabled = true; } } if (selectedLeague == null && Properties.Settings.Default.LeagueId.Length > 0) { logger.Debug($"Get league {Properties.Settings.Default.LeagueId}"); var league = await httpClientService.GetLeagueAsync(Properties.Settings.Default.LeagueId).ConfigureAwait(true); if (league != null) { var item = new ComboBoxItem { Text = league.Id, Value = league, }; leagueRaceCombo.Items.Add(item); leagueRaceCombo.SelectedIndexChanged -= LeagueRaceCombo_SelectedIndexChanged; leagueRaceCombo.SelectedItem = item; leagueRaceCombo.SelectedIndexChanged += LeagueRaceCombo_SelectedIndexChanged; selectedLeague = league; leagueUrlLink.Enabled = false; } } DisplayLeagueInfo(); InitializeCharactersList(); }
/// <summary> /// /// </summary> /// <param name="iteratorSport"></param> /// <returns></returns> private ISport SportPinnacleParse(String urlPathLeague, String urlPathFeed, XPathNodeIterator iteratorSport) { ISport _sport = new Sport(); XPathNavigator _sportNameNavigator = iteratorSport.Current.Clone(); int feedContentSport = Convert.ToInt32(_sportNameNavigator.GetAttribute("feedContents", "")); if (feedContentSport > 0) { // ISport _sport = new Sport(); _sport.ID = Convert.ToInt32(_sportNameNavigator.GetAttribute("id", "")); _sport.Name = _sportNameNavigator.Value; //Add sport to List // sports.Add(_sport); //league- event XmlTextReader readerLeague = new XmlTextReader(string.Format(urlPathLeague, _sport.ID)); readerLeague.WhitespaceHandling = WhitespaceHandling.Significant; XPathDocument docLeague = new XPathDocument(readerLeague, XmlSpace.Preserve); XPathNavigator navLeague = docLeague.CreateNavigator(); XPathExpression exprLeague; exprLeague = navLeague.Compile("/rsp/leagues/league"); XPathNodeIterator iteratorLeague = navLeague.Select(exprLeague); // Loop all Leagues in each sport while (iteratorLeague.MoveNext()) { ILeague _league = LeaguePinnacleParse(urlPathFeed, _sport.ID, _sportNameNavigator, iteratorLeague); if (_sport.Leagues == null) { _sport.Leagues = new List <ILeague>(); } //check league not null if (_league != null) { _sport.Leagues.Add(_league); } } } return(_sport); }
public static ITeam GetTeam(this ILeague league, string id) { return(league.Conferences.SelectMany(c => c.Divisions).SelectMany(d => d.Teams).FirstOrDefault(t => t.ID == id)); }
public static IDivision GetDivision(this ILeague league, string conferenceName, string divisionName) { return(league.GetConference(conferenceName).Divisions.FirstOrDefault(d => d.Name == divisionName)); }
public static IConference GetConference(this ILeague league, string conferenceName) { return(league.Conferences.FirstOrDefault(c => c.Name == conferenceName)); }
public ILeague BuildNFLLeague(string statsFilePath, string leagueFilePath, int weeks = 17) { XmlDocument data = new XmlDocument(); data.Load(statsFilePath); List <Game> allGames = PreLoadGames(data, weeks); data.Load(leagueFilePath); var nflStructure = data["NFLLeague"]["Conferences"].ChildNodes.Cast <XmlNode>(); ILeague league = (ILeague)GetClassInstance("FootballObjects.League", new object[] { "NFL", nflStructure.Select(c => (IConference)GetClassInstance("FootballObjects.Conference", new object[] { c["ConferenceName"].InnerText, c["Divisions"].Cast <XmlNode>().Select(d => (IDivision)GetClassInstance("FootballObjects.Division", new object[] { d["DivisionName"].InnerText, d["Teams"].Cast <XmlNode>().Select(t => (ITeam)GetClassInstance("FootballObjects.Team", new object[] { t["City"].InnerText, t["NickName"].InnerText, t["ID"].InnerText, allGames.Where(g => g.HomeTeam == t["ID"].InnerText || g.AwayTeam == t["ID"].InnerText).Select(g => (IGame)GetClassInstance("FootballObjects.Game", new object[] { g.Date, g.Week, g.HomeTeam, g.AwayTeam, g.HomePoints, g.AwayPoints, (IGameStats)GetClassInstance("FootballObjects.GameStats", new object[] { g.HomeStats.Touchdowns, g.HomeStats.TouchdownsAllowed, g.HomeStats.FieldGoals, g.HomeStats.FirstDowns, g.HomeStats.PassingYards, g.HomeStats.RushingYards, g.HomeStats.Penalties, g.HomeStats.PenaltyYards, g.HomeStats.Turnovers, g.HomeStats.Punts, g.HomeStats.PuntYards, g.HomeStats.TimeOfPosession }), (IGameStats)GetClassInstance("FootballObjects.GameStats", new object[] { g.AwayStats.Touchdowns, g.AwayStats.TouchdownsAllowed, g.AwayStats.FieldGoals, g.AwayStats.FirstDowns, g.AwayStats.PassingYards, g.AwayStats.RushingYards, g.AwayStats.Penalties, g.AwayStats.PenaltyYards, g.AwayStats.Turnovers, g.AwayStats.Punts, g.AwayStats.PuntYards, g.AwayStats.TimeOfPosession }) })).ToArray() })).ToArray() })).ToArray() })).ToArray() }); return(league); }