diff --git a/Storage/Storage/Internal/Operation/ILCOperation.cs b/Storage/Storage/Internal/Operation/ILCOperation.cs index 1c9512d..658a2c8 100644 --- a/Storage/Storage/Internal/Operation/ILCOperation.cs +++ b/Storage/Storage/Internal/Operation/ILCOperation.cs @@ -1,7 +1,7 @@ using System.Collections; namespace LeanCloud.Storage.Internal.Operation { - public interface ILCOperation { + internal interface ILCOperation { ILCOperation MergeWithPrevious(ILCOperation previousOp); object Encode(); diff --git a/Storage/Storage/LCCloud.cs b/Storage/Storage/LCCloud.cs index 830d3ca..a27cc30 100644 --- a/Storage/Storage/LCCloud.cs +++ b/Storage/Storage/LCCloud.cs @@ -76,7 +76,7 @@ namespace LeanCloud.Storage { static object EncodeLCObject(LCObject obj) { obj.ApplyCustomProperties(); - Dictionary dict = LCObjectData.Encode(obj.Data); + Dictionary dict = LCObjectData.Encode(obj.data); dict["__type"] = "Object"; return dict; } diff --git a/Storage/Storage/LCHookObject.cs b/Storage/Storage/LCHookObject.cs index 5b9cc09..c764896 100644 --- a/Storage/Storage/LCHookObject.cs +++ b/Storage/Storage/LCHookObject.cs @@ -15,17 +15,6 @@ namespace LeanCloud.Storage { public partial class LCObject { internal const string IgnoreHooksKey = "__ignore_hooks"; - internal HashSet ignoreHooks; - - internal HashSet IgnoreHooks { - get { - if (ignoreHooks == null) { - ignoreHooks = new HashSet(); - } - return ignoreHooks; - } - } - public void DisableBeforeHook() { Ignore( LCClassHook.BeforeSave, diff --git a/Storage/Storage/LCObject.cs b/Storage/Storage/LCObject.cs index 8f828e0..76ef2b1 100644 --- a/Storage/Storage/LCObject.cs +++ b/Storage/Storage/LCObject.cs @@ -16,9 +16,7 @@ namespace LeanCloud.Storage { /// /// Last synced data. /// - public LCObjectData Data { - get; - } + internal LCObjectData data; /// /// Estimated data. @@ -35,25 +33,25 @@ namespace LeanCloud.Storage { public string ClassName { get { - return Data.ClassName; + return data.ClassName; } } public string ObjectId { get { - return Data.ObjectId; + return data.ObjectId; } } public DateTime CreatedAt { get { - return Data.CreatedAt; + return data.CreatedAt; } } public DateTime UpdatedAt { get { - return Data.UpdatedAt; + return data.UpdatedAt; } } @@ -77,11 +75,11 @@ namespace LeanCloud.Storage { if (string.IsNullOrEmpty(className)) { throw new ArgumentNullException(nameof(className)); } - Data = new LCObjectData(); + data = new LCObjectData(); estimatedData = new Dictionary(); operationDict = new Dictionary(); - Data.ClassName = className; + data.ClassName = className; isNew = true; } @@ -90,7 +88,7 @@ namespace LeanCloud.Storage { throw new ArgumentNullException(nameof(objectId)); } LCObject obj = Create(className); - obj.Data.ObjectId = objectId; + obj.data.ObjectId = objectId; obj.isNew = false; return obj; } @@ -456,7 +454,7 @@ namespace LeanCloud.Storage { /// /// public override string ToString() { - Dictionary originalData = LCObjectData.Encode(Data); + Dictionary originalData = LCObjectData.Encode(data); Dictionary currentData = estimatedData.Union(originalData.Where(kv => !estimatedData.ContainsKey(kv.Key))) .ToDictionary(k => k.Key, v => v.Value); return JsonConvert.SerializeObject(currentData); @@ -492,17 +490,17 @@ namespace LeanCloud.Storage { } public void Merge(LCObjectData objectData) { - Data.ClassName = objectData.ClassName ?? Data.ClassName; - Data.ObjectId = objectData.ObjectId ?? Data.ObjectId; - Data.CreatedAt = objectData.CreatedAt != null ? objectData.CreatedAt : Data.CreatedAt; - Data.UpdatedAt = objectData.UpdatedAt != null ? objectData.UpdatedAt : Data.UpdatedAt; + data.ClassName = objectData.ClassName ?? data.ClassName; + data.ObjectId = objectData.ObjectId ?? data.ObjectId; + data.CreatedAt = objectData.CreatedAt != null ? objectData.CreatedAt : data.CreatedAt; + data.UpdatedAt = objectData.UpdatedAt != null ? objectData.UpdatedAt : data.UpdatedAt; // 先将本地的预估数据直接替换 ApplyCustomProperties(); // 再将服务端的数据覆盖 foreach (KeyValuePair kv in objectData.CustomPropertyDict) { string key = kv.Key; object value = kv.Value; - Data.CustomPropertyDict[key] = value; + data.CustomPropertyDict[key] = value; } // 最后重新生成预估数据,用于后续访问和操作 @@ -513,12 +511,12 @@ namespace LeanCloud.Storage { } public void ApplyCustomProperties() { - Data.CustomPropertyDict = estimatedData; + data.CustomPropertyDict = estimatedData; } void RebuildEstimatedData() { estimatedData = new Dictionary(); - foreach (KeyValuePair kv in Data.CustomPropertyDict) { + foreach (KeyValuePair kv in data.CustomPropertyDict) { string key = kv.Key; object value = kv.Value; if (value is IList list) {