public static MailInfo Decode(G2Header root) { MailInfo info = new MailInfo(); G2Header child = new G2Header(root.Data); while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD) { if (!G2Protocol.ReadPayload(child)) { continue; } switch (child.Name) { case Packet_Subject: info.Subject = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize); break; case Packet_Format: info.Format = (TextFormat)CompactNum.ToInt32(child.Data, child.PayloadPos, child.PayloadSize); break; case Packet_Quip: info.Quip = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize); break; case Packet_Date: info.Date = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos)); break; case Packet_Attachments: info.Attachments = BitConverter.ToBoolean(child.Data, child.PayloadPos); break; case Packet_Unique: info.Unique = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize); break; } } return(info); }
public static MailInfo Decode(G2Header root) { MailInfo info = new MailInfo(); G2Header child = new G2Header(root.Data); while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD) { if (!G2Protocol.ReadPayload(child)) continue; switch (child.Name) { case Packet_Subject: info.Subject = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize); break; case Packet_Format: info.Format = (TextFormat)CompactNum.ToInt32(child.Data, child.PayloadPos, child.PayloadSize); break; case Packet_Quip: info.Quip = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize); break; case Packet_Date: info.Date = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos)); break; case Packet_Attachments: info.Attachments = BitConverter.ToBoolean(child.Data, child.PayloadPos); break; case Packet_Unique: info.Unique = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize); break; } } return info; }