public override void ParsePerson(Result person) { if (string.IsNullOrWhiteSpace(person?.location?.state)) { return; } decimal statePopulation = decimal.Zero; StatePersonCount.TryGetValue(person.location.state, out statePopulation); statePopulation++; TotalSampleSize++; StatePersonCount[person.location.state] = statePopulation; }
protected override IDictionary <string, decimal> GetResults() { var results = new Dictionary <string, decimal>(); // most populous states at the top of the dictionary var topTen = StatePersonCount .OrderByDescending(sm => sm.Value) .Take(10); foreach (var state in topTen) { var percent = CalculatePercent(state.Value, TotalSampleSize); results.Add(state.Key, percent); } return(results); }