在下面的示例中:
Class1 序列化所花费的时间几乎是 Class2 序列化的两倍吗?或者 protobuf-net 会将 Class1 中的 byte[] 作为已经序列化的数据处理?
伪示例:
[ProtoContract]
class Class1
{
[ProtoMember(1)]
public byte[] SerializedData { get; set; }
}
[ProtoContract]
class Class2
{
[ProtoMember(1)]
public Class3 NonSerializedData { get; set; }
}
[ProtoContract]
class Class3
{
[ProtoMember(1)]
public string Address{ get; set; }
[ProtoMember(2)]
public string ZipCode{ get; set; }
[ProtoMember(2)]
public string Country{ get; set; }
}
Class3 _c3 = new Class3() { Address = "MyAddress", ZipCode = "90210", Country = "AZ" }
// Class 1 Serialization
Class1 _c1 = new C1();
_c1.SerializedData = protobuf.Serialize(_c3);
byte[] c1Bytes = protobuf.Serialize(_c1);
// Class 2 Serialization
Class2 _c2 = new Class2();
_c2.NonSerializedData = _c3;
byte[] c2Bytes = protobuf.Serialize(_c2);