예제 #1
0
		private void FoundResults(ParseObject[] array, NSError error)
		{
			//If there was an error or no High scores found, create an emtpy list.
			if (array == null || error != null) {
				Root = new RootElement("High Scores"){
					new Section(){
						new StringElement("No Scores Found"),
					}
				};
				return;
			}
			var easySection = new Section("Easy");
			var mediumSection = new Section("Medium");
			var hardSection = new Section("Hard");

			var objects = array.Select(x=> x.ToObject<GameScore>()).OrderByDescending(x=> x.Score).ToList();

			foreach(var score in objects)
			{
				var element = new StringElement(score.Player,score.Score.ToString("#,###"));
				switch(score.Dificulty)
				{
				case GameDificulty.Easy:
					easySection.Add(element);
					break;
				case GameDificulty.Medium:
					mediumSection.Add(element);
					break;
				case GameDificulty.Hard:
					hardSection.Add (element);
					break;
				}
			}
			Root = new RootElement("High Scores")
			{
				easySection,
				mediumSection,
				hardSection,
			};
			
		}