From 65183c63bf1649813857ce8bbcb452be8f299d94 Mon Sep 17 00:00:00 2001 From: oneRain Date: Thu, 30 Apr 2020 16:03:01 +0800 Subject: [PATCH 1/2] chore: storage readme --- README.md | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f14c33..ad20675 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,87 @@ # csharp-sdk -LeanCloud C# SDK + +LeanCloud 数据存储,即时通讯 C# SDK,基于 .Net Standard 2.0 标准开发。 + +## 安装 + +从 [Release](https://github.com/leancloud/csharp-sdk/releases) 下载指定版本 SDK,暂不支持 Nuget 方式。 + +## 导入 + +```csharp +using LeanCloud; +// 数据存储 +using LeanCloud.Storage; +// 即时通讯 +using LeanCloud.Realtime; +``` + +## 初始化 + +```csharp +LCApplication.Initialize("ikGGdRE2YcVOemAaRbgp1xGJ-gzGzoHsz", "NUKmuRbdAhg1vrb2wexYo1jo", "https://ikggdre2.lc-cn-n1-shared.com"); +``` + +## 调试 + +开启调试日志 + +```csharp +LCLogger.LogDelegate += (level, info) => { + switch (level) { + case LCLogLevel.Debug: + WriteLine($"[DEBUG] {DateTime.Now} {info}\n"); + break; + case LCLogLevel.Warn: + WriteLine($"[WARNING] {DateTime.Now} {info}\n"); + break; + case LCLogLevel.Error: + WriteLine($"[ERROR] {DateTime.Now} {info}\n"); + break; + default: + WriteLine(info); + break; + } +} +``` + +## 用法 + +### 对象 + +```csharp +LCObject obj = new LCObject("Hello"); +obj["intValue"] = 123; +await obj.Save(); +``` + +### 查询 + +```csharp +LCQuery query = new LCQuery("Hello"); +query.Limit(2); +List list = await query.Find(); +``` + +### 文件 + +```csharp +LCFile file = new LCFile("avatar", AvatarFilePath); +await file.Save((count, total) => { + TestContext.WriteLine($"progress: {count}/{total}"); +}); +``` + +### 用户 + +```csharp +await LCUser.Login("hello", "world"); +``` + +### GeoPoint + +```csharp +LCGeoPoint p1 = new LCGeoPoint(20.0059, 110.3665); +``` [API 文档](https://leancloud.github.io/csharp-sdk/html/index.html) From 1e4732a5a5e247bd19cbaab191e5fad13789ec40 Mon Sep 17 00:00:00 2001 From: oneRain Date: Thu, 30 Apr 2020 16:22:04 +0800 Subject: [PATCH 2/2] readme --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ad20675..51ee764 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ LCLogger.LogDelegate += (level, info) => { } ``` -## 用法 +## 数据存储 ### 对象 @@ -55,6 +55,8 @@ obj["intValue"] = 123; await obj.Save(); ``` +更多关于**对象**用法:[参考](https://github.com/leancloud/csharp-sdk/blob/master/Storage/Storage.Test/ObjectTest.cs) + ### 查询 ```csharp @@ -63,6 +65,8 @@ query.Limit(2); List list = await query.Find(); ``` +更多关于**查询**用法:[参考](https://github.com/leancloud/csharp-sdk/blob/master/Storage/Storage.Test/QueryTest.cs) + ### 文件 ```csharp @@ -72,16 +76,67 @@ await file.Save((count, total) => { }); ``` +更多关于**文件**用法:[参考](https://github.com/leancloud/csharp-sdk/blob/master/Storage/Storage.Test/FileTest.cs) + ### 用户 ```csharp await LCUser.Login("hello", "world"); ``` +更多关于**用户**用法:[参考](https://github.com/leancloud/csharp-sdk/blob/master/Storage/Storage.Test/UserTest.cs) + ### GeoPoint ```csharp LCGeoPoint p1 = new LCGeoPoint(20.0059, 110.3665); ``` +更多关于 **GeoPoint** 用法:[参考](https://github.com/leancloud/csharp-sdk/blob/master/Storage/Storage.Test/GeoTest.cs) + +## 即时通讯 + +### 用户 + +```csharp +LCIMClient client = new LCIMClient("c1"); +// 登录 +await client.Open(); +// 注销 +await client.Close(); +``` + +更多关于**用户**用法:[参考](https://github.com/leancloud/csharp-sdk/blob/master/Realtime/Realtime.Test/Client.cs) + +### 对话 + +```csharp +// 创建普通对话 +LCIMConversation conversation = await client.CreateConversation(new string[] { "world" }, name: name, unique: false); +// 创建聊天室 +LCIMConversation chatroom = await client.CreateChatRoom(name); +// 创建临时对话 +LCIMConversation tempConversation = await client.CreateTemporaryConversation(new string[] { "world" }); +``` + +更多关于**对话**用法:[参考](https://github.com/leancloud/csharp-sdk/blob/master/Realtime/Realtime.Test/Conversation.cs) + +### 消息 + +```csharp +// 发送消息 +LCIMTextMessage textMessage = new LCIMTextMessage("hello, world"); +await conversation.Send(textMessage); +// 接收消息 +m2.OnMessage = (conv, msg) => { + if (msg is LCIMTextMessage textMsg) { + WriteLine($"text: {textMsg.Text}"); + } +}; +``` + +更多关于**对话**用法:[参考](https://github.com/leancloud/csharp-sdk/blob/master/Realtime/Realtime.Test/Message.cs) + +## 文档 + [API 文档](https://leancloud.github.io/csharp-sdk/html/index.html)