private static void SerializeCustomer(CharBuffer b, Marlee.Jsv.Console.Program.Customer c) { b.Write('{'); if (c.Name != null) { b.Write("Name:"); WriteString(b, c.Name); b.Write(','); } b.Write("ID:"); b.Write(c.ID); b.Write(','); if (c.Roles != null) { b.Write("Roles:["); for (var i = 0; i < c.Roles.Count; i++) { WriteString(b, c.Roles[i]); b.Write(']'); } b.Write(']'); b.Write(','); } if (c.Address != null) { SerializeAddress(b, c.Address); b.Write(','); } if (c.PhoneNumbers != null) { b.Write("PhoneNumbers:["); for (var i = 0; i < c.PhoneNumbers.Count; i++) { SerializePhoneNumber(b, c.PhoneNumbers[i]); } b.Write(']'); b.Write(','); } if (c.FirstName != null) { b.Write("FirstName:"); WriteString(b, c.FirstName); b.Write(','); } if (c.LastName != null) { b.Write("LastName:"); WriteString(b, c.LastName); b.Write(','); } b.Write("Age:"); b.Write(c.Age); b.Write('}'); }
private static void SerializeAddress(CharBuffer b, Marlee.Jsv.Console.Program.Address a) { b.Write('{'); if (a.Street != null) { b.Write("Street:"); WriteString(b, a.Street); b.Write(','); } b.Write("ID:"); b.Write(a.ID); b.Write('}'); }
internal static void SerializeCustomerBytes(Marlee.Jsv.Console.Program.Customer c, Stream s) { //var byteBuffer = new ByteBuffer(256); //byteBuffer.WriteInt32(4); //byteBuffer.WriteChar('{'); //byteBuffer.WriteString("test"); //var s = byteBuffer.ToString(); var byteBuffer = new CharBuffer(256); SerializeCustomer(byteBuffer, c); byteBuffer.WriteToStream(s); //var x = byteBuffer.ToString(); }
private static void SerializePhoneNumber(CharBuffer b, Marlee.Jsv.Console.Program.PhoneNumber p) { b.Write('{'); if (p.Number != null) { b.Write("Number:"); WriteString(b, p.Number); b.Write(','); } b.Write("Type:"); switch (p.Type) { case Marlee.Jsv.Console.Program.PhoneNumberTypes.Land: b.Write("Land"); break; case Marlee.Jsv.Console.Program.PhoneNumberTypes.Mobile: b.Write("Mobile"); break; } b.Write('}'); }