/* public static MongoMessage FromBytes(byte[] data) * { * using (var stream = new MemoryStream(data)) * { * var message = new MongoMessage(); * * /* // read message id from memory stream until SPACE character * var messageIdBuilder = new StringBuilder(); * do * { * // it is safe to read digits as bytes because they encoded by single byte in UTF-8 * int charCode = stream.ReadByte(); * if (charCode == -1) * { * throw new EndOfStreamException(); * } * char c = (char)charCode; * if (c == ' ') * { * message.Id = ulong.Parse(messageIdBuilder.ToString(), CultureInfo.InvariantCulture); * messageIdBuilder = null; * } * else * { * messageIdBuilder.Append(c); * } * } * while (messageIdBuilder != null);#1# * * var binaryReader = new BinaryReader(stream); * int count = binaryReader.ReadInt32(); * byte[] buffer = binaryReader.ReadBytes(count); * * message = ScaleoutMessage.FromBytes(buffer); * return message; * } * }*/ public static ScaleoutMessage FromBytes(MongoMessage msg) { return(ScaleoutMessage.FromBytes(msg.Value)); }
/* public static MongoMessage FromBytes(byte[] data) { using (var stream = new MemoryStream(data)) { var message = new MongoMessage(); /* // read message id from memory stream until SPACE character var messageIdBuilder = new StringBuilder(); do { // it is safe to read digits as bytes because they encoded by single byte in UTF-8 int charCode = stream.ReadByte(); if (charCode == -1) { throw new EndOfStreamException(); } char c = (char)charCode; if (c == ' ') { message.Id = ulong.Parse(messageIdBuilder.ToString(), CultureInfo.InvariantCulture); messageIdBuilder = null; } else { messageIdBuilder.Append(c); } } while (messageIdBuilder != null);#1# var binaryReader = new BinaryReader(stream); int count = binaryReader.ReadInt32(); byte[] buffer = binaryReader.ReadBytes(count); message = ScaleoutMessage.FromBytes(buffer); return message; } }*/ public static ScaleoutMessage FromBytes(MongoMessage msg) { return ScaleoutMessage.FromBytes(msg.Value); }