csharp-sdk-upm/Storage/Internal/Operation/LCSetOperation.cs

34 lines
846 B
C#
Raw Normal View History

2020-02-19 18:50:51 +08:00
using System;
2020-02-20 12:44:33 +08:00
using System.Collections;
using System.Collections.Generic;
using LeanCloud.Storage.Internal.Codec;
namespace LeanCloud.Storage.Internal.Operation {
internal class LCSetOperation : ILCOperation {
object value;
internal LCSetOperation(object value) {
this.value = value;
2020-02-19 18:50:51 +08:00
}
2020-02-20 12:44:33 +08:00
public ILCOperation MergeWithPrevious(ILCOperation previousOp) {
return this;
}
public object Encode() {
return LCEncoder.Encode(value);
2020-02-20 12:44:33 +08:00
}
public object Apply(object oldValue, string key) {
return value;
}
public IEnumerable GetNewObjectList() {
if (value is IEnumerable enumerable) {
return enumerable;
}
return new List<object> { value };
}
2020-02-19 18:50:51 +08:00
}
}