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