示例#1
0
		private static kcsapi_ranking_getlist Serialize(Session session)
		{
			try
			{
				var djson = DynamicJson.Parse(session.GetResponseAsJson());
				var rankings = new kcsapi_ranking_getlist
				{
					api_count = Convert.ToInt32(djson.api_data.api_count),
					api_disp_page = Convert.ToInt32(djson.api_data.api_disp_page),
					api_page_count = Convert.ToInt32(djson.api_data.api_page_count),
				};

				var list = new List<kcsapi_ranking>();
				var serializer = new DataContractJsonSerializer(typeof(kcsapi_ranking));
				foreach (var x in (object[])djson.api_data.api_list)
				{
					try
					{
						list.Add(serializer.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(x.ToString()))) as kcsapi_ranking);
					}
					catch (SerializationException ex)
					{
						Debug.WriteLine(ex.Message);
					}
				}
				rankings.api_list = list.ToArray();
				return rankings;
			}
			catch (Exception ex)
			{
				Debug.WriteLine(ex);
				return null;
			}
		}
示例#2
0
		private void Update(kcsapi_ranking_getlist ranklist)
		{
			this.TotalRanked = ranklist.api_count;
			this.TotalPages = ranklist.api_page_count;
			this.CurrentPage = ranklist.api_disp_page;

			this.currentData.Clear();
			ranklist.api_list.Select(x => new Ranking(x))
				.ForEach(x => this.currentData.AddOrUpdate(x.Id, x, (_, __) => x));

			this.RaisePropertyChanged("Current");
		}