From 52044b9071ae6fa6a7d23cb34fb879475265badb Mon Sep 17 00:00:00 2001 From: oneRain Date: Mon, 19 Apr 2021 17:11:26 +0800 Subject: [PATCH] doc: leaderboard --- .../Public/Leaderboard/LCLeaderboard.cs | 102 ++++++++++++++++-- .../Storage/Public/Leaderboard/LCRanking.cs | 15 +++ .../Storage/Public/Leaderboard/LCStatistic.cs | 12 +++ 3 files changed, 122 insertions(+), 7 deletions(-) diff --git a/Storage/Storage/Public/Leaderboard/LCLeaderboard.cs b/Storage/Storage/Public/Leaderboard/LCLeaderboard.cs index 9cab449..0730081 100644 --- a/Storage/Storage/Public/Leaderboard/LCLeaderboard.cs +++ b/Storage/Storage/Public/Leaderboard/LCLeaderboard.cs @@ -26,35 +26,68 @@ namespace LeanCloud.Storage { Month } + /// + /// LCLeaderboard represents LeanCloud leaderboard and contains static functions + /// that handle the statistic. + /// public class LCLeaderboard { + /// + /// The name of statistic. + /// public string StatisticName { get; private set; } + /// + /// The order of this leaderboard. + /// public LCLeaderboardOrder Order { get; private set; } + /// + /// The update strategy of this leaderboard. + /// public LCLeaderboardUpdateStrategy UpdateStrategy { get; private set; } + /// + /// The interval of the version that the leaderboard resets. + /// public LCLeaderboardVersionChangeInterval VersionChangeInterval { get; private set; } + /// + /// The version of this leaderboard. + /// public int Version { get; private set; } + /// + /// The next time that the leaderboard resets. + /// public DateTime NextResetAt { get; private set; } + /// + /// The time that the leaderboard created. + /// public DateTime CreatedAt { get; private set; } + /// + /// Creates a LCLeaderboard with a statistic name. + /// + /// + /// + /// + /// + /// public static async Task CreateLeaderboard(string statisticName, LCLeaderboardOrder order = LCLeaderboardOrder.Descending, LCLeaderboardUpdateStrategy updateStrategy = LCLeaderboardUpdateStrategy.Better, @@ -90,12 +123,23 @@ namespace LeanCloud.Storage { }; } + /// + /// Gets the LCLeaderboard with the given name. + /// + /// + /// public static Task GetLeaderboard(string statisticName) { LCLeaderboard leaderboard = CreateWithoutData(statisticName); return leaderboard.Fetch(); } - + /// + /// Updates the statistic of the user. + /// + /// + /// + /// + /// public static async Task> UpdateStatistics(LCUser user, Dictionary statistics, bool overwrite = false) { @@ -127,7 +171,12 @@ namespace LeanCloud.Storage { return null; } - + /// + /// Gets the statistics of the user. + /// + /// + /// + /// public static async Task> GetStatistics(LCUser user, IEnumerable statisticNames = null) { if (user == null) { @@ -151,7 +200,12 @@ namespace LeanCloud.Storage { return null; } - + /// + /// Deletes the statistics of the user with the given name. + /// + /// + /// + /// public static async Task DeleteStatistics(LCUser user, IEnumerable statisticNames) { if (user == null) { @@ -195,7 +249,15 @@ namespace LeanCloud.Storage { return null; } - + /// + /// Gets the rankings. + /// + /// + /// + /// + /// + /// + /// public Task> GetResults(int version = -1, int skip = 0, int limit = 10, @@ -204,7 +266,15 @@ namespace LeanCloud.Storage { return GetResults(null, version, skip, limit, selectUserKeys, includeStatistics); } - + /// + /// Get the rankings that around the currently logged in user. + /// + /// + /// + /// + /// + /// + /// public async Task> GetResultsAroundUser(int version = -1, int skip = 0, int limit = 10, @@ -214,6 +284,16 @@ namespace LeanCloud.Storage { return await GetResults(user, version, skip, limit, selectUserKeys, includeStatistics); } + /// + /// Gets the rankings of the user. + /// + /// + /// + /// + /// + /// + /// + /// private async Task> GetResults(LCUser user, int version, int skip, @@ -249,7 +329,11 @@ namespace LeanCloud.Storage { return null; } - + /// + /// Updates the update strategy of this LCLeaderboard. + /// + /// + /// public async Task UpdateUpdateStrategy(LCLeaderboardUpdateStrategy updateStrategy) { Dictionary data = new Dictionary { { "updateStrategy", updateStrategy.ToString().ToLower() } @@ -264,7 +348,11 @@ namespace LeanCloud.Storage { return this; } - + /// + /// Updates the interval of the version that this LCLeaderboard changes. + /// + /// + /// public async Task UpdateVersionChangeInterval(LCLeaderboardVersionChangeInterval versionChangeInterval) { Dictionary data = new Dictionary { { "versionChangeInterval", versionChangeInterval.ToString().ToLower() } diff --git a/Storage/Storage/Public/Leaderboard/LCRanking.cs b/Storage/Storage/Public/Leaderboard/LCRanking.cs index ea3ca9c..1474e2c 100644 --- a/Storage/Storage/Public/Leaderboard/LCRanking.cs +++ b/Storage/Storage/Public/Leaderboard/LCRanking.cs @@ -4,19 +4,34 @@ using System.Collections.ObjectModel; using LeanCloud.Storage.Internal.Object; namespace LeanCloud.Storage { + /// + /// LCRanking represents the rankings of LCLeaderboard. + /// public class LCRanking { + /// + /// The ranking. + /// public int Rank { get; private set; } + /// + /// The user of this LCRanking. + /// public LCUser User { get; private set; } + /// + /// The statistic name of this LCRanking. + /// public string StatisticName { get; private set; } + /// + /// The value of this LCRanking. + /// public double Value { get; private set; } diff --git a/Storage/Storage/Public/Leaderboard/LCStatistic.cs b/Storage/Storage/Public/Leaderboard/LCStatistic.cs index a9823a5..5f26624 100644 --- a/Storage/Storage/Public/Leaderboard/LCStatistic.cs +++ b/Storage/Storage/Public/Leaderboard/LCStatistic.cs @@ -2,15 +2,27 @@ using System.Collections.Generic; namespace LeanCloud.Storage { + /// + /// LCStatistic represents the statistic of LeanCloud leaderboard. + /// public class LCStatistic { + /// + /// The name of this LCStatistic. + /// public string Name { get; private set; } + /// + /// The value of this LCStatistic. + /// public double Value { get; private set; } + /// + /// The version of this LCStatistic. + /// public int Version { get; internal set; }