* ObjectTest.cs: chore: 移除旧代码

* AVUser.cs:
* AVObject.cs:
* SubClassTest.cs:
* AVExtensions.cs:
* AVObjectExtensions.cs:
* AVQueryController.cs:
* AVObjectController.cs:
oneRain 2019-12-11 17:03:23 +08:00
parent a839ccc96d
commit a9ce795c45
8 changed files with 215 additions and 737 deletions

View File

@ -178,6 +178,7 @@ namespace LeanCloud.Test {
await account.DeleteAsync(condition);
account = new AVObject("Account") {
{ "name", "acl account" },
{ "balance", 8 },
};
account.ACL = new AVACL {

View File

@ -38,8 +38,8 @@ namespace LeanCloud.Test {
public async Task SubClass() {
AVObject.RegisterSubclass<Account>();
AVQuery<Account> query = new AVQuery<Account>();
IEnumerable<Account> accountList = await query.FindAsync();
foreach (Account account in accountList) {
IEnumerable<Account> accounts = await query.FindAsync();
foreach (Account account in accounts) {
Assert.NotNull(account.Name);
Assert.Greater(account.Balance, 0);
TestContext.Out.WriteLine($"{account.Name}, {account.Balance}");

View File

@ -92,12 +92,5 @@ namespace LeanCloud.Storage.Internal {
}
return list;
}
public async Task DeleteAllAsync(IList<IObjectState> states,
CancellationToken cancellationToken) {
// TODO 判断是否全部失败或者网络错误
}
}
}

View File

@ -9,8 +9,7 @@ namespace LeanCloud.Storage.Internal {
public class AVQueryController {
public async Task<IEnumerable<IObjectState>> FindAsync<T>(AVQuery<T> query, CancellationToken cancellationToken) where T : AVObject {
IList<object> items = await FindAsync<IList<object>>(query.Path, query.BuildParameters(), "results", cancellationToken);
return from item in items
select AVObjectCoder.Instance.Decode(item as IDictionary<string, object>, AVDecoder.Instance);
return items.Select(item => AVObjectCoder.Instance.Decode(item as IDictionary<string, object>, AVDecoder.Instance));
}
public async Task<int> CountAsync<T>(AVQuery<T> query, CancellationToken cancellationToken) where T : AVObject {

View File

@ -45,11 +45,6 @@ namespace LeanCloud.Storage.Internal
return PointerOrLocalIdEncoder.Instance.EncodeAVObject(obj, false);
}
public static void SetIfDifferent<T>(this AVObject obj, string key, T value)
{
obj.SetIfDifferent<T>(key, value);
}
public static IDictionary<string, object> ServerDataToJSONObjectForSerialization(this AVObject obj)
{
return obj.ServerDataToJSONObjectForSerialization();

View File

@ -18,9 +18,9 @@ namespace LeanCloud {
/// </summary>
/// <param name="objects">The objects to save.</param>
/// <param name="cancellationToken">The cancellation token.</param>
public static Task SaveAllAsync<T>(this IEnumerable<T> objects, bool fetchWhenSave = false, AVQuery<AVObject> query = null, CancellationToken cancellationToken = default)
public static Task SaveAllAsync<T>(this IEnumerable<T> objects, CancellationToken cancellationToken = default)
where T : AVObject {
return AVObject.SaveAllAsync(objects, fetchWhenSave, query, cancellationToken);
return AVObject.SaveAllAsync(objects, cancellationToken);
}
/// <summary>
@ -100,25 +100,5 @@ namespace LeanCloud {
}
return obj.FetchAsyncInternal(queryString, cancellationToken).OnSuccess(t => (T)t.Result);
}
/// <summary>
/// If this AVObject has not been fetched (i.e. <see cref="AVObject.IsDataAvailable"/> returns
/// false), fetches this object with the data from the server.
/// </summary>
/// <param name="obj">The AVObject to fetch.</param>
public static Task<T> FetchIfNeededAsync<T>(this T obj) where T : AVObject {
return obj.FetchIfNeededAsyncInternal(CancellationToken.None).OnSuccess(t => (T)t.Result);
}
/// <summary>
/// If this AVObject has not been fetched (i.e. <see cref="AVObject.IsDataAvailable"/> returns
/// false), fetches this object with the data from the server.
/// </summary>
/// <param name="obj">The AVObject to fetch.</param>
/// <param name="cancellationToken">The cancellation token.</param>
public static Task<T> FetchIfNeededAsync<T>(this T obj, CancellationToken cancellationToken)
where T : AVObject {
return obj.FetchIfNeededAsyncInternal(cancellationToken).OnSuccess(t => (T)t.Result);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -151,10 +151,8 @@ namespace LeanCloud {
/// </summary>
/// <returns></returns>
public async Task<bool> IsAuthenticatedAsync() {
lock (mutex) {
if (SessionToken == null || CurrentUser == null || CurrentUser.ObjectId != ObjectId) {
return false;
}
if (SessionToken == null || CurrentUser == null || CurrentUser.ObjectId != ObjectId) {
return false;
}
var command = new AVCommand {
Path = $"users/me?session_token={SessionToken}",