比方說,我有一個類MyClass
:更新的對象已序列化
[ProtoContract]
public class MyClass
{
[ProtoMember(1)]
public string PropA { get; set; }
[ProtoMember(2)]
public string PropB { get; set; }
// ...
[ProtoMember(12)]
public string PropL { get; set; }
}
我也得到了一個List<MyClass>
和protobuf網二進制反序列化到它。如何更新序列化文件(可能包含數百或數千個序列化的MyClass
對象)中包含的MyClass
實例?我看了一些馬克對其他問題提出的意見,並就好像我需要使用Deserialize
並傳遞MyClass
實例,但唯一的方法簽名我看到的是
public static T Deserialize<T>(System.IO.Stream source)
也許我需要使用合併?我不確定我應該如何使用它。
public static T MergeWithLengthPrefix<T>(System.IO.Stream source, T instance, ProtoBuf.PrefixStyle style)
我正在使用protobuf-net v2.0.0.480。
你最後建議的答案是我現在正在做的。我或多或少只是想知道是否可以對文件中的序列化對象進行就地更新。 – Brett