* AVCommandRunner.cs: chore: 格式化代码
* AVUser.cs: * AVCloud.cs: * IAVCommandRunner.cs: * AVFileController.cs:
parent
a951d8e6c5
commit
6a42f1f74a
|
@ -38,7 +38,7 @@ namespace LeanCloud.Storage.Internal
|
||||||
public Task<Tuple<HttpStatusCode, IDictionary<string, object>>> RunCommandAsync(AVCommand command,
|
public Task<Tuple<HttpStatusCode, IDictionary<string, object>>> RunCommandAsync(AVCommand command,
|
||||||
IProgress<AVUploadProgressEventArgs> uploadProgress = null,
|
IProgress<AVUploadProgressEventArgs> uploadProgress = null,
|
||||||
IProgress<AVDownloadProgressEventArgs> downloadProgress = null,
|
IProgress<AVDownloadProgressEventArgs> downloadProgress = null,
|
||||||
CancellationToken cancellationToken = default(CancellationToken))
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return PrepareCommand(command).ContinueWith(commandTask =>
|
return PrepareCommand(command).ContinueWith(commandTask =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,6 +19,6 @@ namespace LeanCloud.Storage.Internal
|
||||||
Task<Tuple<HttpStatusCode, IDictionary<string, object>>> RunCommandAsync(AVCommand command,
|
Task<Tuple<HttpStatusCode, IDictionary<string, object>>> RunCommandAsync(AVCommand command,
|
||||||
IProgress<AVUploadProgressEventArgs> uploadProgress = null,
|
IProgress<AVUploadProgressEventArgs> uploadProgress = null,
|
||||||
IProgress<AVDownloadProgressEventArgs> downloadProgress = null,
|
IProgress<AVDownloadProgressEventArgs> downloadProgress = null,
|
||||||
CancellationToken cancellationToken = default(CancellationToken));
|
CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,17 @@ using System.Net;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace LeanCloud.Storage.Internal
|
namespace LeanCloud.Storage.Internal {
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// AVF ile controller.
|
/// AVF ile controller.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AVFileController : IAVFileController
|
public class AVFileController : IAVFileController {
|
||||||
{
|
|
||||||
private readonly IAVCommandRunner commandRunner;
|
private readonly IAVCommandRunner commandRunner;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="T:LeanCloud.Storage.Internal.AVFileController"/> class.
|
/// Initializes a new instance of the <see cref="T:LeanCloud.Storage.Internal.AVFileController"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="commandRunner">Command runner.</param>
|
/// <param name="commandRunner">Command runner.</param>
|
||||||
public AVFileController(IAVCommandRunner commandRunner)
|
public AVFileController(IAVCommandRunner commandRunner) {
|
||||||
{
|
|
||||||
this.commandRunner = commandRunner;
|
this.commandRunner = commandRunner;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -34,18 +31,15 @@ namespace LeanCloud.Storage.Internal
|
||||||
/// <param name="cancellationToken">Cancellation token.</param>
|
/// <param name="cancellationToken">Cancellation token.</param>
|
||||||
public virtual Task<FileState> SaveAsync(FileState state,
|
public virtual Task<FileState> SaveAsync(FileState state,
|
||||||
Stream dataStream,
|
Stream dataStream,
|
||||||
String sessionToken,
|
string sessionToken,
|
||||||
IProgress<AVUploadProgressEventArgs> progress,
|
IProgress<AVUploadProgressEventArgs> progress,
|
||||||
CancellationToken cancellationToken = default(CancellationToken))
|
CancellationToken cancellationToken = default) {
|
||||||
{
|
if (state.Url != null) {
|
||||||
if (state.Url != null)
|
|
||||||
{
|
|
||||||
// !isDirty
|
// !isDirty
|
||||||
return Task<FileState>.FromResult(state);
|
return Task<FileState>.FromResult(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cancellationToken.IsCancellationRequested)
|
if (cancellationToken.IsCancellationRequested) {
|
||||||
{
|
|
||||||
var tcs = new TaskCompletionSource<FileState>();
|
var tcs = new TaskCompletionSource<FileState>();
|
||||||
tcs.TrySetCanceled();
|
tcs.TrySetCanceled();
|
||||||
return tcs.Task;
|
return tcs.Task;
|
||||||
|
@ -60,30 +54,25 @@ namespace LeanCloud.Storage.Internal
|
||||||
|
|
||||||
return commandRunner.RunCommandAsync(command,
|
return commandRunner.RunCommandAsync(command,
|
||||||
uploadProgress: progress,
|
uploadProgress: progress,
|
||||||
cancellationToken: cancellationToken).OnSuccess(uploadTask =>
|
cancellationToken: cancellationToken).OnSuccess(uploadTask => {
|
||||||
{
|
|
||||||
var result = uploadTask.Result;
|
var result = uploadTask.Result;
|
||||||
var jsonData = result.Item2;
|
var jsonData = result.Item2;
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
return new FileState
|
return new FileState {
|
||||||
{
|
|
||||||
Name = jsonData["name"] as string,
|
Name = jsonData["name"] as string,
|
||||||
Url = new Uri(jsonData["url"] as string, UriKind.Absolute),
|
Url = new Uri(jsonData["url"] as string, UriKind.Absolute),
|
||||||
MimeType = state.MimeType
|
MimeType = state.MimeType
|
||||||
};
|
};
|
||||||
}).ContinueWith(t =>
|
}).ContinueWith(t => {
|
||||||
{
|
|
||||||
// Rewind the stream on failure or cancellation (if possible)
|
// Rewind the stream on failure or cancellation (if possible)
|
||||||
if ((t.IsFaulted || t.IsCanceled) && dataStream.CanSeek)
|
if ((t.IsFaulted || t.IsCanceled) && dataStream.CanSeek) {
|
||||||
{
|
|
||||||
dataStream.Seek(oldPosition, SeekOrigin.Begin);
|
dataStream.Seek(oldPosition, SeekOrigin.Begin);
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}).Unwrap();
|
}).Unwrap();
|
||||||
}
|
}
|
||||||
public Task DeleteAsync(FileState state, string sessionToken, CancellationToken cancellationToken)
|
public Task DeleteAsync(FileState state, string sessionToken, CancellationToken cancellationToken) {
|
||||||
{
|
|
||||||
var command = new AVCommand("files/" + state.ObjectId,
|
var command = new AVCommand("files/" + state.ObjectId,
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
sessionToken: sessionToken,
|
sessionToken: sessionToken,
|
||||||
|
@ -91,8 +80,7 @@ namespace LeanCloud.Storage.Internal
|
||||||
|
|
||||||
return commandRunner.RunCommandAsync(command, cancellationToken: cancellationToken);
|
return commandRunner.RunCommandAsync(command, cancellationToken: cancellationToken);
|
||||||
}
|
}
|
||||||
internal static Task<Tuple<HttpStatusCode, IDictionary<string, object>>> GetFileToken(FileState fileState, CancellationToken cancellationToken)
|
internal static Task<Tuple<HttpStatusCode, IDictionary<string, object>>> GetFileToken(FileState fileState, CancellationToken cancellationToken) {
|
||||||
{
|
|
||||||
Task<Tuple<HttpStatusCode, IDictionary<string, object>>> rtn;
|
Task<Tuple<HttpStatusCode, IDictionary<string, object>>> rtn;
|
||||||
string currentSessionToken = AVUser.CurrentSessionToken;
|
string currentSessionToken = AVUser.CurrentSessionToken;
|
||||||
string str = fileState.Name;
|
string str = fileState.Name;
|
||||||
|
@ -107,43 +95,37 @@ namespace LeanCloud.Storage.Internal
|
||||||
|
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
public Task<FileState> GetAsync(string objectId, string sessionToken, CancellationToken cancellationToken)
|
public Task<FileState> GetAsync(string objectId, string sessionToken, CancellationToken cancellationToken) {
|
||||||
{
|
|
||||||
var command = new AVCommand("files/" + objectId,
|
var command = new AVCommand("files/" + objectId,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
sessionToken: sessionToken,
|
sessionToken: sessionToken,
|
||||||
data: null);
|
data: null);
|
||||||
|
|
||||||
return commandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).OnSuccess(_ =>
|
return commandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).OnSuccess(_ => {
|
||||||
{
|
|
||||||
var result = _.Result;
|
var result = _.Result;
|
||||||
var jsonData = result.Item2;
|
var jsonData = result.Item2;
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
return new FileState
|
return new FileState {
|
||||||
{
|
|
||||||
ObjectId = jsonData["objectId"] as string,
|
ObjectId = jsonData["objectId"] as string,
|
||||||
Name = jsonData["name"] as string,
|
Name = jsonData["name"] as string,
|
||||||
Url = new Uri(jsonData["url"] as string, UriKind.Absolute),
|
Url = new Uri(jsonData["url"] as string, UriKind.Absolute),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
internal static string GetUniqueName(FileState fileState)
|
internal static string GetUniqueName(FileState fileState) {
|
||||||
{
|
|
||||||
string key = Random(12);
|
string key = Random(12);
|
||||||
string extension = Path.GetExtension(fileState.Name);
|
string extension = Path.GetExtension(fileState.Name);
|
||||||
key += extension;
|
key += extension;
|
||||||
fileState.CloudName = key;
|
fileState.CloudName = key;
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
internal static string Random(int length)
|
internal static string Random(int length) {
|
||||||
{
|
|
||||||
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
|
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
|
||||||
var random = new Random();
|
var random = new Random();
|
||||||
return new string(Enumerable.Repeat(chars, length)
|
return new string(Enumerable.Repeat(chars, length)
|
||||||
.Select(s => s[random.Next(s.Length)]).ToArray());
|
.Select(s => s[random.Next(s.Length)]).ToArray());
|
||||||
}
|
}
|
||||||
internal static double CalcProgress(double already, double total)
|
internal static double CalcProgress(double already, double total) {
|
||||||
{
|
|
||||||
var pv = (1.0 * already / total);
|
var pv = (1.0 * already / total);
|
||||||
return Math.Round(pv, 3);
|
return Math.Round(pv, 3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace LeanCloud {
|
||||||
/// <param name="sesstionToken"></param>
|
/// <param name="sesstionToken"></param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>The result of the cloud call.</returns>
|
/// <returns>The result of the cloud call.</returns>
|
||||||
public static Task<T> CallFunctionAsync<T>(String name, IDictionary<string, object> parameters = null, string sesstionToken = null, CancellationToken cancellationToken = default(CancellationToken))
|
public static Task<T> CallFunctionAsync<T>(string name, IDictionary<string, object> parameters = null, string sesstionToken = null, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var sessionTokenTask = AVUser.TakeSessionToken(sesstionToken);
|
var sessionTokenTask = AVUser.TakeSessionToken(sesstionToken);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace LeanCloud {
|
||||||
/// <param name="sesstionToken"></param>
|
/// <param name="sesstionToken"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Task<T> RPCFunctionAsync<T>(String name, IDictionary<string, object> parameters = null, string sesstionToken = null, CancellationToken cancellationToken = default(CancellationToken))
|
public static Task<T> RPCFunctionAsync<T>(string name, IDictionary<string, object> parameters = null, string sesstionToken = null, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var sessionTokenTask = AVUser.TakeSessionToken(sesstionToken);
|
var sessionTokenTask = AVUser.TakeSessionToken(sesstionToken);
|
||||||
|
|
||||||
|
@ -108,20 +108,6 @@ namespace LeanCloud {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 请求短信认证。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mobilePhoneNumber">手机号。</param>
|
|
||||||
/// <param name="name">应用名称。</param>
|
|
||||||
/// <param name="op">进行的操作名称。</param>
|
|
||||||
/// <param name="ttl">验证码失效时间。</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static Task<bool> RequestSMSCodeAsync(string mobilePhoneNumber, string name, string op, int ttl = 10)
|
|
||||||
{
|
|
||||||
return RequestSMSCodeAsync(mobilePhoneNumber, name, op, ttl, CancellationToken.None);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 请求发送验证码。
|
/// 请求发送验证码。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -131,7 +117,7 @@ namespace LeanCloud {
|
||||||
/// <param name="op">进行的操作名称。</param>
|
/// <param name="op">进行的操作名称。</param>
|
||||||
/// <param name="ttl">验证码失效时间。</param>
|
/// <param name="ttl">验证码失效时间。</param>
|
||||||
/// <param name="cancellationToken">Cancellation token。</param>
|
/// <param name="cancellationToken">Cancellation token。</param>
|
||||||
public static Task<bool> RequestSMSCodeAsync(string mobilePhoneNumber, string name, string op, int ttl = 10, CancellationToken cancellationToken = default(CancellationToken))
|
public static Task<bool> RequestSMSCodeAsync(string mobilePhoneNumber, string name, string op, int ttl = 10, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(mobilePhoneNumber))
|
if (string.IsNullOrEmpty(mobilePhoneNumber))
|
||||||
{
|
{
|
||||||
|
@ -202,8 +188,7 @@ namespace LeanCloud {
|
||||||
string template,
|
string template,
|
||||||
IDictionary<string, object> env,
|
IDictionary<string, object> env,
|
||||||
string sign = "",
|
string sign = "",
|
||||||
string validateToken = "",
|
string validateToken = "")
|
||||||
CancellationToken cancellationToken = default(CancellationToken))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(mobilePhoneNumber))
|
if (string.IsNullOrEmpty(mobilePhoneNumber))
|
||||||
|
@ -318,7 +303,7 @@ namespace LeanCloud {
|
||||||
/// <param name="code">User's input of this captcha.</param>
|
/// <param name="code">User's input of this captcha.</param>
|
||||||
/// <param name="cancellationToken">CancellationToken.</param>
|
/// <param name="cancellationToken">CancellationToken.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task VerifyAsync(string code, CancellationToken cancellationToken = default(CancellationToken))
|
public Task VerifyAsync(string code)
|
||||||
{
|
{
|
||||||
return AVCloud.VerifyCaptchaAsync(code, Token);
|
return AVCloud.VerifyCaptchaAsync(code, Token);
|
||||||
}
|
}
|
||||||
|
@ -331,10 +316,10 @@ namespace LeanCloud {
|
||||||
/// <param name="height">captcha image height.</param>
|
/// <param name="height">captcha image height.</param>
|
||||||
/// <param name="cancellationToken">CancellationToken.</param>
|
/// <param name="cancellationToken">CancellationToken.</param>
|
||||||
/// <returns>an instance of Captcha.</returns>
|
/// <returns>an instance of Captcha.</returns>
|
||||||
public static Task<Captcha> RequestCaptchaAsync(int width = 85, int height = 30, CancellationToken cancellationToken = default(CancellationToken))
|
public static Task<Captcha> RequestCaptchaAsync(int width = 85, int height = 30, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var path = String.Format("requestCaptcha?width={0}&height={1}", width, height);
|
var path = String.Format("requestCaptcha?width={0}&height={1}", width, height);
|
||||||
var command = new AVCommand(path, method: "GET", sessionToken: null, data: null);
|
var command = new AVCommand(path, "GET", null, data: null);
|
||||||
return AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).OnSuccess(t =>
|
return AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).OnSuccess(t =>
|
||||||
{
|
{
|
||||||
var decoded = AVDecoder.Instance.Decode(t.Result.Item2) as IDictionary<string, object>;
|
var decoded = AVDecoder.Instance.Decode(t.Result.Item2) as IDictionary<string, object>;
|
||||||
|
@ -353,14 +338,14 @@ namespace LeanCloud {
|
||||||
/// <param name="code">User's input of this captcha.</param>
|
/// <param name="code">User's input of this captcha.</param>
|
||||||
/// <param name="cancellationToken">CancellationToken.</param>
|
/// <param name="cancellationToken">CancellationToken.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Task<string> VerifyCaptchaAsync(string code, string token, CancellationToken cancellationToken = default(CancellationToken))
|
public static Task<string> VerifyCaptchaAsync(string code, string token, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var data = new Dictionary<string, object>
|
var data = new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
{ "captcha_token", token },
|
{ "captcha_token", token },
|
||||||
{ "captcha_code", code },
|
{ "captcha_code", code },
|
||||||
};
|
};
|
||||||
var command = new AVCommand("verifyCaptcha", method: "POST", sessionToken: null, data: data);
|
var command = new AVCommand("verifyCaptcha", "POST", null, data: data);
|
||||||
return AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).ContinueWith(t =>
|
return AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).ContinueWith(t =>
|
||||||
{
|
{
|
||||||
if (!t.Result.Item2.ContainsKey("validate_token"))
|
if (!t.Result.Item2.ContainsKey("validate_token"))
|
||||||
|
@ -374,7 +359,7 @@ namespace LeanCloud {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Task<IDictionary<string, object>> GetCustomParametersAsync(CancellationToken cancellationToken = default(CancellationToken))
|
public static Task<IDictionary<string, object>> GetCustomParametersAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var command = new AVCommand(string.Format("statistics/apps/{0}/sendPolicy", AVClient.CurrentConfiguration.ApplicationId),
|
var command = new AVCommand(string.Format("statistics/apps/{0}/sendPolicy", AVClient.CurrentConfiguration.ApplicationId),
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
@ -397,7 +382,7 @@ namespace LeanCloud {
|
||||||
public string Signature { internal set; get; }
|
public string Signature { internal set; get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task<RealtimeSignature> RequestRealtimeSignatureAsync(CancellationToken cancellationToken = default(CancellationToken))
|
public static Task<RealtimeSignature> RequestRealtimeSignatureAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return AVUser.GetCurrentUserAsync(cancellationToken).OnSuccess(t =>
|
return AVUser.GetCurrentUserAsync(cancellationToken).OnSuccess(t =>
|
||||||
{
|
{
|
||||||
|
@ -405,7 +390,7 @@ namespace LeanCloud {
|
||||||
}).Unwrap();
|
}).Unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task<RealtimeSignature> RequestRealtimeSignatureAsync(AVUser user, CancellationToken cancellationToken = default(CancellationToken))
|
public static Task<RealtimeSignature> RequestRealtimeSignatureAsync(AVUser user, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
var command = new AVCommand(string.Format("rtm/sign"),
|
var command = new AVCommand(string.Format("rtm/sign"),
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -518,7 +503,7 @@ namespace LeanCloud {
|
||||||
var user = t.Result;
|
var user = t.Result;
|
||||||
var encodedParameters = Encode(parameters);
|
var encodedParameters = Encode(parameters);
|
||||||
var command = new AVCommand(
|
var command = new AVCommand(
|
||||||
string.Format("call/{0}", Uri.EscapeUriString(this.FunctionName)),
|
string.Format("call/{0}", Uri.EscapeUriString(FunctionName)),
|
||||||
method: "POST",
|
method: "POST",
|
||||||
sessionToken: user != null ? user.SessionToken : null,
|
sessionToken: user != null ? user.SessionToken : null,
|
||||||
data: encodedParameters);
|
data: encodedParameters);
|
||||||
|
|
|
@ -147,7 +147,7 @@ namespace LeanCloud
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Task<string> GetCurrentSessionTokenAsync(CancellationToken cancellationToken = default(CancellationToken))
|
internal static Task<string> GetCurrentSessionTokenAsync(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return CurrentUserController.GetCurrentSessionTokenAsync(cancellationToken);
|
return CurrentUserController.GetCurrentSessionTokenAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
|
@ -936,24 +936,13 @@ namespace LeanCloud
|
||||||
return AVUser.LogInByMobilePhoneNumberAsync(mobilePhoneNumber, password, CancellationToken.None);
|
return AVUser.LogInByMobilePhoneNumberAsync(mobilePhoneNumber, password, CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 以手机号和验证码匹配登陆
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mobilePhoneNumber">手机号</param>
|
|
||||||
/// <param name="smsCode">短信验证码</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static Task<AVUser> LogInBySmsCodeAsync(string mobilePhoneNumber, string smsCode)
|
|
||||||
{
|
|
||||||
return AVUser.LogInBySmsCodeAsync(mobilePhoneNumber, smsCode, CancellationToken.None);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用邮箱作和密码匹配登录
|
/// 用邮箱作和密码匹配登录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="email">邮箱</param>
|
/// <param name="email">邮箱</param>
|
||||||
/// <param name="password">密码</param>
|
/// <param name="password">密码</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Task<AVUser> LogInByEmailAsync(string email, string password, CancellationToken cancellationToken = default(CancellationToken))
|
public static Task<AVUser> LogInByEmailAsync(string email, string password, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return UserController.LogInAsync(null, email, password, cancellationToken).OnSuccess(t => {
|
return UserController.LogInAsync(null, email, password, cancellationToken).OnSuccess(t => {
|
||||||
AVUser user = AVObject.FromState<AVUser>(t.Result, "_User");
|
AVUser user = AVObject.FromState<AVUser>(t.Result, "_User");
|
||||||
|
@ -986,7 +975,7 @@ namespace LeanCloud
|
||||||
/// <param name="smsCode">短信验证码</param>
|
/// <param name="smsCode">短信验证码</param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Task<AVUser> LogInBySmsCodeAsync(string mobilePhoneNumber, string smsCode, CancellationToken cancellationToken = default(CancellationToken))
|
public static Task<AVUser> LogInBySmsCodeAsync(string mobilePhoneNumber, string smsCode, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
Dictionary<string, object> strs = new Dictionary<string, object>()
|
Dictionary<string, object> strs = new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
|
@ -1127,7 +1116,7 @@ namespace LeanCloud
|
||||||
/// <param name="smsCode">Sms code.</param>
|
/// <param name="smsCode">Sms code.</param>
|
||||||
public static Task<AVUser> LogInByMobilePhoneAsync(string mobilePhoneNumber, string smsCode)
|
public static Task<AVUser> LogInByMobilePhoneAsync(string mobilePhoneNumber, string smsCode)
|
||||||
{
|
{
|
||||||
return AVUser.LogInBySmsCodeAsync(mobilePhoneNumber, smsCode);
|
return LogInBySmsCodeAsync(mobilePhoneNumber, smsCode);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in New Issue