views:

394

answers:

1

I'm developing a C# application on Windows Mobile, and like most of my WM applications, I always get bogged down whenever I'm deciding on a serialization strategy. In the desktop world, I'm not too worried about it because i've already developed a pretty robust custom xml serializer - however, in the WM world, I don't want to use it because of the reflection performance penalties.

So I develop everything against Data Access Objects (DAO) interfaces, so I can easily swap out different implementations for serializing to xml, registry, sqlce, etc. While developing in the beginning, I usually implement a non-persistent in-memory DAO (using Dictionary<>), followed by a XmlSerializer DAO when I want to persist data, and then when everything's completed, move to a full-blown sqlce DAO.

However, in my latest app, I can't use an XmlSerializer DAO because of how badly it (doesn't) handle properties that are interfaces. IE, I have a Foo object which contains a List< IBar > Bars property, XmlSerializer can't serialize it (although I was easily able to develop my own custom xml serializer which could - go figure).

All that to ask this question: What DAO strategies have you found to help you develop applications for WM? Do you plan ahead for several different DAOs at different app maturity levels? Do you start at the full-blown sqlce DAO? What would you recommend for a quick-and-easy persistent serialization DAO when XmlSerializer can't be used?

+1  A: 

Well, it doesn't necessarily apply in your case (since it, like XmlSerializer, wants concrete types), but protobuf-net is a binary serialization engine that works on all .NET variants, including CF 2.0 and CF 3.5; this would allow you to store data, and to exchange it with your full-fat 3.5 server (or, indeed, with java, perl, php, etc).

It is certainly quick and easy, so would definitely be worth a look-in if you want portable data in WM.

Marc Gravell
What would you suggest if portability wasn't a concern, but performance and ease of development is?
ZaijiaN
Well, performance-wise, on CF 3.5, protobuf-net out-performs XmlSerializer/DataContractSerializer, while being similar (or identical) in terms of attributes etc - so I'd use that, but then - I'm biased ;-p Note that on CF 2.0 (without Delegate.CreateDelegate) it isn't quite as fast, but still works.
Marc Gravell