private static BasicCompetition GetCompetion(string competitionName) { BasicCompetition competition = null; if (!Competitions.TryGetValue(competitionName, out competition)) { competition = new StrengthCompetition(competitionName); if (CacheFile && HttpContext.Current != null) { var pricingResult = HttpContext.Current.Server.MapPath("~/Pricer/"); if (File.Exists(pricingResult + competitionName + ".xml")) { try { XmlSerializer xs = new XmlSerializer(typeof(PricerResult)); using (StreamReader rd = new StreamReader(pricingResult + competitionName + ".xml")) { var pricerResult = (PricerResult)(xs.Deserialize(rd)); var prizes = pricerResult.Prizes.Split('-').Select(x => Convert.ToInt32(x)).ToList(); competition.Simulation = new HashSet <SimulationResult>(pricerResult.Scenarios.Select(x => { var teamsId = x.Teams.Split('-'); var length = teamsId.Length; var results = new Dictionary <int, int>(length); for (int i = 0; i < length; i++) { var teamId = teamsId[i]; results[Convert.ToInt32(teamId)] = prizes[i]; } var simulationResult = new SimulationResult(results, x.Value); return(simulationResult); })); competition.Simulation.TrimExcess(); } } catch (Exception) { } } } Competitions[competitionName] = competition; } return(competition); }
protected bool Equals(SimulationResult other) { return(Key.SequenceEqual(other.Key)); }