/// <summary> /// Serialize message as stream. /// </summary> /// <param name="writeContextType"></param> /// <returns></returns> public static NetStream Serialize(this IQueueItem message, bool writeContextType) { NetStream ns = new NetStream(); var streamer = new BinaryStreamer(ns); if (writeContextType) { streamer.WriteContextType(SerialContextType.SerialEntityType); } message.EntityWrite(ns, streamer); return(ns); }