doc: readme

oneRain 2020-05-14 10:39:51 +08:00
parent 080aa1c049
commit b1e29f9b70
2 changed files with 124 additions and 24 deletions

100
README.md
View File

@ -137,6 +137,106 @@ m2.OnMessage = (conv, msg) => {
更多关于**对话**用法:[参考](https://github.com/leancloud/csharp-sdk/blob/master/Realtime/Realtime.Test/Message.cs)
## 排行榜
### 创建排行榜
```csharp
LCLeaderboard leaderboard = await LCLeaderboard.CreateLeaderboard(leaderboardName);
```
### 更新成绩
```csharp
await LCLeaderboard.UpdateStatistics(user, new Dictionary<string, double> {
{ leaderboardName, 100 }
});
```
### 获取成绩
```csharp
LCUser user = await LCUser.Login(username, password);
ReadOnlyCollection<LCStatistic> statistics = await LCLeaderboard.GetStatistics(user);
foreach (LCStatistic statistic in statistics) {
WriteLine($"{statistic.Name} : {statistic.Value}");
}
```
### 获取我附近的成绩
```csharp
await LCUser.Login(username, password);
LCLeaderboard leaderboard = LCLeaderboard.CreateWithoutData(leaderboardName);
ReadOnlyCollection<LCRanking> rankings = await leaderboard.GetResultsAroundUser(limit: 5);
foreach (LCRanking ranking in rankings) {
WriteLine($"{ranking.Rank} : {ranking.User.ObjectId}, {ranking.Value}");
}
```
### 获取榜单
```csharp
LCLeaderboard leaderboard = LCLeaderboard.CreateWithoutData(leaderboardName);
ReadOnlyCollection<LCRanking> rankings = await leaderboard.GetResults();
foreach (LCRanking ranking in rankings) {
WriteLine($"{ranking.Rank} : {ranking.User.ObjectId}, {ranking.Value}");
}
```
## LiveQuery
### 订阅
```csharp
LCQuery<LCObject> query = new LCQuery<LCObject>("Account");
query.WhereGreaterThan("balance", 100);
liveQuery = await query.Subscribe();
```
### 事件
```csharp
// 新建符合条件对象的事件
liveQuery.OnCreate = (obj) => {
WriteLine($"create: {obj}");
};
// 符合条件对象更新事件
liveQuery.OnUpdate = (obj, updatedKeys) => {
WriteLine($"update: {obj}");
};
// 符合条件对象被删除事件
liveQuery.OnDelete = (objId) => {
WriteLine($"delete: {objId}");
};
// 有新的符合条件的对象事件
liveQuery.OnEnter = (obj, updatedKeys) => {
WriteLine($"enter: {obj}");
};
// 有符合条件的对象不再满足条件事件
liveQuery.OnLeave = (obj, updatedKeys) => {
WriteLine($"level: {obj}");
};
```
### 特殊事件
当一个用户成功登录应用OnLogin 事件会被触发。下面的 user 就是登录的 LCUser:
```csharp
await LCUser.Login("hello", "world");
LCQuery<LCUser> userQuery = LCUser.GetQuery();
userQuery.WhereEqualTo("username", "hello");
LCLiveQuery userLiveQuery = await userQuery.Subscribe();
userLiveQuery.OnLogin = (user) => {
WriteLine($"login: {user}");
};
```
## 文档
[API 文档](https://leancloud.github.io/csharp-sdk/html/index.html)

View File

@ -29,13 +29,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RealtimeApp", "Sample\Realt
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LiveQuery", "LiveQuery", "{A1A24E0F-6901-4A9A-9BB8-4F586BC7EE17}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveQuery", "LiveQuery\LiveQuery\LiveQuery.csproj", "{659BA438-1DA7-4A32-92A4-DD0FAE142259}"
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "LiveQueryApp", "Sample\LiveQueryApp\LiveQueryApp.csproj", "{FBB9B634-672E-4C13-8D30-AAC6429BB3CA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveQuery.Test", "LiveQuery\LiveQuery.Test\LiveQuery.Test.csproj", "{7F770CE0-593E-486A-96E8-8903BC27C6FB}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveQuery", "LiveQuery\LiveQuery\LiveQuery.csproj", "{02D23AC7-FBF7-49ED-994F-C1D0D3C3ABFE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveQueryApp", "Sample\LiveQueryApp\LiveQueryApp.csproj", "{CF72C053-5DB9-4E9C-BF9D-6664672F4916}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveQuery.Test", "LiveQuery\LiveQuery.Test\LiveQuery.Test.csproj", "{0F61B6D7-4948-4D98-B6CC-41CF33B55669}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveQuery-Unity", "LiveQuery\LiveQuery-Unity\LiveQuery-Unity.csproj", "{FF11B077-93F1-45FD-A3C7-020D316EB5A4}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveQuery-Unity", "LiveQuery\LiveQuery-Unity\LiveQuery-Unity.csproj", "{12482E48-C0CF-46B1-8FDD-5885D1B7DC4D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -79,22 +79,22 @@ Global
{A716EFC7-9220-4A9A-9F73-B816A0787F77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A716EFC7-9220-4A9A-9F73-B816A0787F77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A716EFC7-9220-4A9A-9F73-B816A0787F77}.Release|Any CPU.Build.0 = Release|Any CPU
{659BA438-1DA7-4A32-92A4-DD0FAE142259}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{659BA438-1DA7-4A32-92A4-DD0FAE142259}.Debug|Any CPU.Build.0 = Debug|Any CPU
{659BA438-1DA7-4A32-92A4-DD0FAE142259}.Release|Any CPU.ActiveCfg = Release|Any CPU
{659BA438-1DA7-4A32-92A4-DD0FAE142259}.Release|Any CPU.Build.0 = Release|Any CPU
{7F770CE0-593E-486A-96E8-8903BC27C6FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F770CE0-593E-486A-96E8-8903BC27C6FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F770CE0-593E-486A-96E8-8903BC27C6FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7F770CE0-593E-486A-96E8-8903BC27C6FB}.Release|Any CPU.Build.0 = Release|Any CPU
{CF72C053-5DB9-4E9C-BF9D-6664672F4916}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CF72C053-5DB9-4E9C-BF9D-6664672F4916}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CF72C053-5DB9-4E9C-BF9D-6664672F4916}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CF72C053-5DB9-4E9C-BF9D-6664672F4916}.Release|Any CPU.Build.0 = Release|Any CPU
{FF11B077-93F1-45FD-A3C7-020D316EB5A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF11B077-93F1-45FD-A3C7-020D316EB5A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF11B077-93F1-45FD-A3C7-020D316EB5A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF11B077-93F1-45FD-A3C7-020D316EB5A4}.Release|Any CPU.Build.0 = Release|Any CPU
{FBB9B634-672E-4C13-8D30-AAC6429BB3CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FBB9B634-672E-4C13-8D30-AAC6429BB3CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBB9B634-672E-4C13-8D30-AAC6429BB3CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FBB9B634-672E-4C13-8D30-AAC6429BB3CA}.Release|Any CPU.Build.0 = Release|Any CPU
{02D23AC7-FBF7-49ED-994F-C1D0D3C3ABFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02D23AC7-FBF7-49ED-994F-C1D0D3C3ABFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02D23AC7-FBF7-49ED-994F-C1D0D3C3ABFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{02D23AC7-FBF7-49ED-994F-C1D0D3C3ABFE}.Release|Any CPU.Build.0 = Release|Any CPU
{0F61B6D7-4948-4D98-B6CC-41CF33B55669}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0F61B6D7-4948-4D98-B6CC-41CF33B55669}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0F61B6D7-4948-4D98-B6CC-41CF33B55669}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0F61B6D7-4948-4D98-B6CC-41CF33B55669}.Release|Any CPU.Build.0 = Release|Any CPU
{12482E48-C0CF-46B1-8FDD-5885D1B7DC4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12482E48-C0CF-46B1-8FDD-5885D1B7DC4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12482E48-C0CF-46B1-8FDD-5885D1B7DC4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12482E48-C0CF-46B1-8FDD-5885D1B7DC4D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{26CDAE2A-6D79-4981-8D80-3EA34FDFB134} = {319A9989-3B69-4AD0-9E43-F6D31C1D2A4A}
@ -106,10 +106,10 @@ Global
{882A9419-CC5E-4CFB-B076-7561989B0A4A} = {319A9989-3B69-4AD0-9E43-F6D31C1D2A4A}
{75A3A4EC-93B8-40C9-AE04-DF14A72525CC} = {319A9989-3B69-4AD0-9E43-F6D31C1D2A4A}
{A716EFC7-9220-4A9A-9F73-B816A0787F77} = {2D980281-F060-4363-AB7A-D4B6C30ADDBB}
{659BA438-1DA7-4A32-92A4-DD0FAE142259} = {A1A24E0F-6901-4A9A-9BB8-4F586BC7EE17}
{7F770CE0-593E-486A-96E8-8903BC27C6FB} = {A1A24E0F-6901-4A9A-9BB8-4F586BC7EE17}
{CF72C053-5DB9-4E9C-BF9D-6664672F4916} = {2D980281-F060-4363-AB7A-D4B6C30ADDBB}
{FF11B077-93F1-45FD-A3C7-020D316EB5A4} = {A1A24E0F-6901-4A9A-9BB8-4F586BC7EE17}
{FBB9B634-672E-4C13-8D30-AAC6429BB3CA} = {2D980281-F060-4363-AB7A-D4B6C30ADDBB}
{02D23AC7-FBF7-49ED-994F-C1D0D3C3ABFE} = {A1A24E0F-6901-4A9A-9BB8-4F586BC7EE17}
{0F61B6D7-4948-4D98-B6CC-41CF33B55669} = {A1A24E0F-6901-4A9A-9BB8-4F586BC7EE17}
{12482E48-C0CF-46B1-8FDD-5885D1B7DC4D} = {A1A24E0F-6901-4A9A-9BB8-4F586BC7EE17}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
version = 0.1.0