chore: for leanengine
parent
70e5b6c3bb
commit
e5b9f29575
|
@ -15,7 +15,7 @@ namespace LeanCloud.Storage.Internal.Codec {
|
|||
return DecodeBytes(dict);
|
||||
} else if (type == "Object") {
|
||||
return DecodeObject(dict);
|
||||
} else if (type == "Pointer") {
|
||||
} else if (type == "Pointer" || type == "Object") {
|
||||
return DecodeObject(dict);
|
||||
} else if (type == "Relation") {
|
||||
return DecodeRelation(dict);
|
||||
|
|
|
@ -65,10 +65,10 @@ namespace LeanCloud.Storage.Internal.Object {
|
|||
if (!string.IsNullOrEmpty(objectData.ObjectId)) {
|
||||
dict["objectId"] = objectData.ObjectId;
|
||||
}
|
||||
if (objectData.CreatedAt != null) {
|
||||
if (!objectData.CreatedAt.Equals(default)) {
|
||||
dict["createdAt"] = objectData.CreatedAt.ToUniversalTime();
|
||||
}
|
||||
if (objectData.UpdatedAt != null) {
|
||||
if (!objectData.UpdatedAt.Equals(default)) {
|
||||
dict["updatedAt"] = objectData.UpdatedAt.ToUniversalTime();
|
||||
}
|
||||
if (objectData.CustomPropertyDict != null) {
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace LeanCloud {
|
|||
/// </summary>
|
||||
public class LCApplication {
|
||||
// SDK 版本号,用于 User-Agent 统计
|
||||
internal const string SDKVersion = "0.6.4";
|
||||
public const string SDKVersion = "0.6.4";
|
||||
|
||||
// 接口版本号,用于接口版本管理
|
||||
internal const string APIVersion = "1.1";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using LeanCloud.Storage.Internal.Codec;
|
||||
using LeanCloud.Storage.Internal.Object;
|
||||
|
||||
namespace LeanCloud.Storage {
|
||||
/// <summary>
|
||||
|
@ -46,11 +47,38 @@ namespace LeanCloud.Storage {
|
|||
Dictionary<string, object> headers = new Dictionary<string, object> {
|
||||
{ PRODUCTION_KEY, IsProduction ? 1 : 0 }
|
||||
};
|
||||
object encodeParams = LCEncoder.Encode(parameters);
|
||||
object encodeParams = Encode(parameters);
|
||||
Dictionary<string, object> response = await LCApplication.HttpClient.Post<Dictionary<string, object>>(path,
|
||||
headers: headers,
|
||||
data: encodeParams);
|
||||
return LCDecoder.Decode(response["result"]);
|
||||
}
|
||||
|
||||
public static object Encode(object parameters) {
|
||||
if (parameters is LCObject lcObj) {
|
||||
return EncodeLCObject(lcObj);
|
||||
} else if (parameters is IList<LCObject> list) {
|
||||
List<object> l = new List<object>();
|
||||
foreach (LCObject obj in list) {
|
||||
l.Add(EncodeLCObject(obj));
|
||||
}
|
||||
return l;
|
||||
} else if (parameters is IDictionary<string, LCObject> dict) {
|
||||
Dictionary<string, object> d = new Dictionary<string, object>();
|
||||
foreach (KeyValuePair<string, LCObject> item in dict) {
|
||||
d[item.Key] = EncodeLCObject(item.Value);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
return parameters;
|
||||
}
|
||||
|
||||
static object EncodeLCObject(LCObject obj) {
|
||||
obj.ApplyCustomProperties();
|
||||
Dictionary<string, object> dict = LCObjectData.Encode(obj.Data);
|
||||
dict["__type"] = "Object";
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -497,7 +497,7 @@ namespace LeanCloud.Storage {
|
|||
Data.CreatedAt = objectData.CreatedAt != null ? objectData.CreatedAt : Data.CreatedAt;
|
||||
Data.UpdatedAt = objectData.UpdatedAt != null ? objectData.UpdatedAt : Data.UpdatedAt;
|
||||
// 先将本地的预估数据直接替换
|
||||
Data.CustomPropertyDict = estimatedData;
|
||||
ApplyCustomProperties();
|
||||
// 再将服务端的数据覆盖
|
||||
foreach (KeyValuePair<string, object> kv in objectData.CustomPropertyDict) {
|
||||
string key = kv.Key;
|
||||
|
@ -512,6 +512,10 @@ namespace LeanCloud.Storage {
|
|||
isNew = false;
|
||||
}
|
||||
|
||||
public void ApplyCustomProperties() {
|
||||
Data.CustomPropertyDict = estimatedData;
|
||||
}
|
||||
|
||||
void RebuildEstimatedData() {
|
||||
estimatedData = new Dictionary<string, object>();
|
||||
foreach (KeyValuePair<string, object> kv in Data.CustomPropertyDict) {
|
||||
|
|
Loading…
Reference in New Issue