Reputation: 451
I have a struct called coordinate which is contained in a list in another class called segment.
public struct Coordinate
{
public double Latitude { get; set; }
public double Longtitude { get; set; }
public double Altitude { get; set; }
public DateTime Time { get; set; }
}
public class Segment
{
private List<Coordinate> coordinates;
...
}
I'd like to serialize the Segment class using the XmlSerializer using Silverlight (on Windows Phone 7). I understand from link text that XmlSerializer doesn't support List<T>
. What is the advised way of serializing a resizable array coordinates?
Thanks, Jurgen
Upvotes: 3
Views: 1323
Reputation: 48147
I always prefer the DataContractSerializer over the XmlSerializer. The XmlSerializer is not available in vanilla Silverlight, but the DataContractSerializer is.
It would not have any problem serializing your structures that you showed.
Upvotes: 2
Reputation: 1063569
Have you tried it? Which bit specifically suggests no lists?
For info, as soon as I have all the tools together (VS2010 / Phone 7 sdk etc) I plan on seeing what protobuf-net can do for Phone 7, but XmlSerializer
should be a solid default.
Upvotes: 1
Reputation: 43317
I am of the opinion that one should always design his own serialization formats. It seems to be a minority opinion these days.
You never know what serializer becomes a file format and you really don't want the ability to read your file formats dependent on .NET framework.
Upvotes: 0