c# - Using ProtoBuf-net to deseriailize a derived type (dictionary) does not properly set object fields -
I am attempting to deserialize an object whose class meets the I have not tried the same work with Follow-up question: Instead, I can redefine the . You can add version data to the dictionary or you can rewrite your DTO object like this sample. If you use this data object, it will correct your exam: The third way is to write your own serialization. dictionary & lt; String, int & gt; with string member field
Public class TempClass: dictionary & lt; String, int & gt; {Public string version; Public Tempelas () {}} I have written a unit test to capture the problem in which I am running: member field is not set, either serializing or deserializing ( / With a byte []) this test with the protofuf-net fails in the last
assurance when it is verified that the deserialized
version is set correctly it is always appropriate
is set to
null instead of "someVersion" .
BinaryFormatter and
DataContractSerializer for any benefit < / P>
TempClass in this way, always, the area is right from the original
Instead of being set to version , the constructor is always called instead how can I deserialize and ring the constellation without creating a new
version If only the original Make a copy?
Public class TempClass: dictionary & lt; String, int & gt; {Public string version; Public TempClass () {Version = DateTime.UtcNow.ToString ("s"); } This effect may be related to the internal receipt of the ordering type of the IDV in the Protocol;}}
[ProtoContract] Public class TempClass {[ProtoMember (1)] Public dictionary & lt; String, int & gt; Information; [Proto member (2)] public string version; Public Templas () {}}
Comments
Post a Comment