public void UnpackFromMessage(Unpacker unpacker) { unpacker.ReadInt32(out count); unpacker.ReadString(out data); }
/// <summary> /// Unpacks the message from a MessagePack object /// This method should not be called directly, use deserialize instead. /// </summary> /// <param name="unpacker">The unpacker</param> public void UnpackFromMessage(Unpacker unpacker) { string dcs, dac, dad, dbd, dbb, day, dau, dag, dai, daj, dak, dcg; int dbc; if (!unpacker.IsMapHeader) throw SerializationExceptions.NewIsNotMapHeader(); if (UnpackHelpers.GetItemsCount(unpacker) != MapCount) throw SerializationExceptions.NewUnexpectedArrayLength(MapCount, UnpackHelpers.GetItemsCount(unpacker)); for (var i = 0; i < MapCount; i++) { string key; if (!unpacker.ReadString(out key)) throw SerializationExceptions.NewUnexpectedEndOfStream(); switch (key) { case "DCS": { if (!unpacker.ReadString(out dcs)) throw SerializationExceptions.NewMissingProperty("dcs"); Dcs = dcs; break; } case "DAC": { if (!unpacker.ReadString(out dac)) throw SerializationExceptions.NewMissingProperty("dac"); Dac = dac; break; } case "DAD": { if (!unpacker.ReadString(out dad)) throw SerializationExceptions.NewMissingProperty("dad"); Dad = dad; break; } case "DBD": { if (!unpacker.ReadString(out dbd)) throw SerializationExceptions.NewMissingProperty("dbd"); Dbd = DateTime.Parse(dbd); break; } case "DBB": { if (!unpacker.ReadString(out dbb)) throw SerializationExceptions.NewMissingProperty("dbb"); Dbb = DateTime.Parse(dbb); break; } case "DBC": { if (!unpacker.ReadInt32(out dbc)) throw SerializationExceptions.NewMissingProperty("dbc"); Dbc = (Sex) dbc; break; } case "DAY": { if (!unpacker.ReadString(out day)) throw SerializationExceptions.NewMissingProperty("day"); Day = GetEyeColor(day); break; } case "DAU": { if (!unpacker.ReadString(out dau)) throw SerializationExceptions.NewMissingProperty("dau"); Dau = new Height {AnsiFormat = dau}; break; } case "DAG": { if (!unpacker.ReadString(out dag)) throw SerializationExceptions.NewMissingProperty("dag"); Dag = dag; break; } case "DAI": { if (!unpacker.ReadString(out dai)) throw SerializationExceptions.NewMissingProperty("dai"); Dai = dai; break; } case "DAJ": { if (!unpacker.ReadString(out daj)) throw SerializationExceptions.NewMissingProperty("daj"); Daj = daj; break; } case "DAK": { if (!unpacker.ReadString(out dak)) throw SerializationExceptions.NewMissingProperty("dak"); Dak = new PostalCode {AnsiFormat = dak}; break; } case "DCG": { if (!unpacker.ReadString(out dcg)) throw SerializationExceptions.NewMissingProperty("dcg"); Dcg = dcg; break; } case "ZAA": { if (!unpacker.Read()) throw SerializationExceptions.NewMissingProperty("zaa"); var ms = new MemoryStream(unpacker.LastReadData.AsBinary()); Image = Image.FromStream(ms); break; } case "ZAB": { if (!unpacker.Read()) throw SerializationExceptions.NewMissingProperty("zab"); Fingerprint = new Fingerprint {AsIsoTemplate = unpacker.LastReadData.AsBinary()}; break; } } } }