Merge pull request #95 from onerain88/chore2
Chore2
commit
2add0af58d
|
@ -32,5 +32,9 @@ namespace LeanCloud.Realtime {
|
|||
public override Task Read() {
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override Task FetchReciptTimestamps() {
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -467,7 +467,7 @@ namespace LeanCloud.Realtime {
|
|||
/// Fetches receipt timestamp.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task FetchReciptTimestamps() {
|
||||
public virtual async Task FetchReciptTimestamps() {
|
||||
await Client.ConversationController.FetchReciptTimestamp(Id);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,5 +17,9 @@ namespace LeanCloud.Realtime {
|
|||
public async Task<bool> CheckSubscription() {
|
||||
return await Client.ConversationController.CheckSubscription(Id);
|
||||
}
|
||||
|
||||
public override Task FetchReciptTimestamps() {
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,8 +120,8 @@ namespace LeanCloud.Realtime {
|
|||
/// <summary>
|
||||
/// Indicates whether this message is transient.
|
||||
/// </summary>
|
||||
public bool IsTransient {
|
||||
get; internal set;
|
||||
internal bool IsTransient {
|
||||
get; set;
|
||||
}
|
||||
|
||||
internal LCIMMessage() {
|
||||
|
|
|
@ -346,12 +346,13 @@ namespace LeanCloud.Storage {
|
|||
return (int)ret["count"];
|
||||
}
|
||||
|
||||
public Task<T> Get(string objectId) {
|
||||
public async Task<T> Get(string objectId) {
|
||||
if (string.IsNullOrEmpty(objectId)) {
|
||||
throw new ArgumentNullException(nameof(objectId));
|
||||
}
|
||||
WhereEqualTo("objectId", objectId);
|
||||
return First();
|
||||
string path = $"classes/{ClassName}/{objectId}";
|
||||
Dictionary<string, object> response = await LCApplication.HttpClient.Get<Dictionary<string, object>>(path);
|
||||
return DecodeLCObject(response);
|
||||
}
|
||||
|
||||
public async Task<ReadOnlyCollection<T>> Find() {
|
||||
|
@ -361,9 +362,7 @@ namespace LeanCloud.Storage {
|
|||
List<object> results = response["results"] as List<object>;
|
||||
List<T> list = new List<T>();
|
||||
foreach (object item in results) {
|
||||
LCObjectData objectData = LCObjectData.Decode(item as Dictionary<string, object>);
|
||||
T obj = LCObject.Create(ClassName) as T;
|
||||
obj.Merge(objectData);
|
||||
T obj = DecodeLCObject(item as Dictionary<string, object>);
|
||||
list.Add(obj);
|
||||
}
|
||||
return list.AsReadOnly();
|
||||
|
@ -412,5 +411,12 @@ namespace LeanCloud.Storage {
|
|||
compositionQuery.ClassName = className;
|
||||
return compositionQuery;
|
||||
}
|
||||
|
||||
private T DecodeLCObject(Dictionary<string, object> data) {
|
||||
LCObjectData objectData = LCObjectData.Decode(data);
|
||||
T obj = LCObject.Create(ClassName) as T;
|
||||
obj.Merge(objectData);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -326,7 +326,7 @@ namespace LeanCloud.Storage {
|
|||
if (string.IsNullOrEmpty(platform)) {
|
||||
throw new ArgumentNullException(nameof(platform));
|
||||
}
|
||||
return LinkWithAuthData(platform, null);
|
||||
return UnlinkWithAuthData(platform);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -523,11 +523,34 @@ namespace LeanCloud.Storage {
|
|||
return new LCQuery<LCUser>(CLASS_NAME);
|
||||
}
|
||||
|
||||
Task LinkWithAuthData(string authType, Dictionary<string, object> data) {
|
||||
async Task LinkWithAuthData(string authType, Dictionary<string, object> data) {
|
||||
Dictionary<string, object> oriAuthData = new Dictionary<string, object>(AuthData);
|
||||
AuthData = new Dictionary<string, object> {
|
||||
{ authType, data }
|
||||
};
|
||||
return Save();
|
||||
try {
|
||||
await Save();
|
||||
oriAuthData.Add(authType, data);
|
||||
AuthData = oriAuthData;
|
||||
} catch (Exception e) {
|
||||
AuthData = oriAuthData;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
async Task UnlinkWithAuthData(string authType) {
|
||||
Dictionary<string, object> oriAuthData = new Dictionary<string, object>(AuthData);
|
||||
AuthData = new Dictionary<string, object> {
|
||||
{ authType, null }
|
||||
};
|
||||
try {
|
||||
await Save();
|
||||
oriAuthData.Remove(authType);
|
||||
AuthData = oriAuthData;
|
||||
} catch (Exception e) {
|
||||
AuthData = oriAuthData;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
static async Task<LCUser> Login(Dictionary<string, object> data) {
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace LeanCloud.Storage {
|
|||
|
||||
public static async Task<ReadOnlyCollection<LCStatistic>> UpdateStatistics(LCUser user,
|
||||
Dictionary<string, double> statistics,
|
||||
bool overwrite = true) {
|
||||
bool overwrite = false) {
|
||||
if (user == null) {
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue