csharp-sdk-upm/Storage/LCCloud.cs

29 lines
1.1 KiB
C#
Raw Normal View History

2020-02-19 18:50:51 +08:00
using System.Threading.Tasks;
using System.Collections.Generic;
using LeanCloud.Storage.Internal.Codec;
2020-02-19 18:50:51 +08:00
namespace LeanCloud.Storage {
/// <summary>
/// 云引擎
/// </summary>
public static class LCCloud {
/// <summary>
/// 调用云函数,结果为 Dictionary 类型
/// </summary>
/// <param name="name"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public static async Task<Dictionary<string, object>> Run(string name, Dictionary<string, object> parameters = null) {
string path = $"functions/{name}";
2020-03-10 16:25:46 +08:00
Dictionary<string, object> response = await LCApplication.HttpClient.Post<Dictionary<string, object>>(path, data: parameters);
2020-02-19 18:50:51 +08:00
return response;
}
public static async Task<object> RPC(string name, Dictionary<string, object> parameters = null) {
2020-02-19 18:50:51 +08:00
string path = $"call/{name}";
2020-03-10 16:25:46 +08:00
Dictionary<string, object> response = await LCApplication.HttpClient.Post<Dictionary<string, object>>(path, data: parameters);
return LCDecoder.Decode(response["result"]);
2020-02-19 18:50:51 +08:00
}
}
}