public static WebCache Decode(G2Header root)
{
WebCache cache = new WebCache();
G2Header child = new G2Header(root.Data);
while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
{
if (!G2Protocol.ReadPayload(child))
continue;
switch (child.Name)
{
case Packet_Address:
cache.Address = UTF8Encoding.UTF8.GetString(child.Data, child.PayloadPos, child.PayloadSize);
break;
case Packet_AccessKey:
cache.AccessKey = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
break;
case Packet_LastSeen:
cache.LastSeen = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos));
break;
case Packet_LastTried:
cache.LastTried = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos));
break;
}
}
return cache;
}