
Untitled
By: a guest on
May 31st, 2012 | syntax:
None | size: 1.36 KB | hits: 17 | expires: Never
Simple Protobuf-net code failing in MonoDroid with 'No serializer defined for type'
[ProtoContract]
public class SSDTO {
[ProtoMember(1)]
public Dictionary<string, string> Strings = new Dictionary<string, string>(50);
[ProtoMember(2)]
public Dictionary<string, int> Ints = new Dictionary<string, int>(50);
[ProtoMember(3)]
public Dictionary<string, byte[]> Bytes = new Dictionary<string, byte[]>(10);
}
public class SettingStore {
public event EventHandler ContentsChanged;
private Dictionary<string, string> _StringVals;
private Dictionary<string, int> _IntVals;
private Dictionary<string, byte[]> _ByteVals;
public SettingStore() {
_StringVals = new Dictionary<string, string>(50);
_IntVals = new Dictionary<string, int>(50);
_ByteVals = new Dictionary<string, byte[]>(10);
}
private SettingStore(SSDTO source) {
_StringVals = source.Strings;
_IntVals = source.Ints;
_ByteVals = source.Bytes;
}
public static SettingStore DeSerialize(Stream data) {
return new SettingStore(Serializer.Deserialize<SSDTO>(data));
}
public void Serialize(Stream Target) {
Serializer.Serialize<SSDTO>(Target, toDTO());
}
private SSDTO toDTO() {
return new SSDTO { Ints = this._IntVals, Strings = this._StringVals, Bytes = this._ByteVals };
}
}