using System; using System.Collections.Generic; using LeanCloud.Storage.Internal; namespace LeanCloud { /// /// 排名类 /// public class AVRanking { /// /// 名次 /// /// The rank. public int Rank { get; private set; } /// /// 用户 /// /// The user. public AVUser User { get; private set; } public string StatisticName { get; private set; } /// /// 分数 /// /// The value. public double Value { get; private set; } /// /// 成绩 /// /// The included statistics. public List IncludedStatistics { get; private set; } AVRanking() { } internal static AVRanking Parse(IDictionary data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } var ranking = new AVRanking { Rank = int.Parse(data["rank"].ToString()), User = AVDecoder.Instance.Decode(data["user"]) as AVUser, StatisticName = data["statisticName"].ToString(), Value = double.Parse(data["statisticValue"].ToString()) }; object statisticsObj; if (data.TryGetValue("statistics", out statisticsObj)) { ranking.IncludedStatistics = new List(); var statisticsObjList = statisticsObj as List; foreach (object statisticObj in statisticsObjList) { var statistic = AVStatistic.Parse(statisticObj as IDictionary); ranking.IncludedStatistics.Add(statistic); } } return ranking; } } }