public void FromBytes(byte[] bytes) { if (bytes[0] == '0') { ContentType = typeof(GoodbyeMessageContent); return; } ContentType = MessageCodes.GetType(bytes); BinaryFormatter formatter = new BinaryFormatter(); Content = (MessageContent) formatter.Deserialize(new MemoryStream(bytes, 2, bytes.Length-2)); }
public GenericMessage(Type t, MessageContent content) { ContentType = t; ContentCode = MessageCodes.FromType(t); Content = content; }