I have a Class that contains objects, arrays, int, and string too.
public class Template
{
[ProtoMember(1)]
public string name;
[ProtoMember(2)]
public tempClass contour;
[ProtoMember(3)]
.
.
.
}
//And here is the Serializing code (Using protobuf-net)
using (var file = File.Create("Templates.bin"))
{
Serializer.Serialize<Template[]>(file, tempArray);
}
I know it can be deserializeable using Objective-c. i tried some solution but did not succeeded yet.
have anyone done this before? is that better to use XML instead of Protobuf?
That will map to (in .proto terms):
message templateWrapper {
repeated template items = 1;
}
message template {
optional string name = 1;
optional tempClass contour = 2;
// ...
}
message tempClass {
// ...
}
And then deserialize as a single templateWrapper
, which will have multiple items
.
Note that all of the .proto schema except for the templateWrapper
should be available via Serializer.GetProto<Template>()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.