/// <summary> /// The unpack from message. /// </summary> /// <param name="unpacker"> /// The unpacker. /// </param> /// <exception cref="NotImplementedException"> /// </exception> public void UnpackFromMessage(Unpacker unpacker) { // Read the type name this.TypeName = unpacker.LastReadData.AsString(); // Read the data object as byte array byte[] temp; unpacker.ReadBinary(out temp); // Create a message serializer object Type type = Type.GetType(this.TypeName); if (type == null) { type = Assembly.GetCallingAssembly().GetType(this.TypeName); if (type == null) { throw new ArgumentException(string.Format("Type '{0}' not found.", this.TypeName)); } } IMessagePackSingleObjectSerializer ser = BaseMessage.serializers[type]; // Unpack the message's data object this.dataObject = (BaseMessage)ser.UnpackSingleObject(temp); }
/// <summary> /// </summary> /// <param name="unpacker"> /// </param> public void UnpackFromMessage(Unpacker unpacker) { // Read the type name this.typeName = unpacker.LastReadData.AsString(); // Read the data object as byte array byte[] temp; unpacker.ReadBinary(out temp); // Create a message serializer object IMessagePackSingleObjectSerializer ser = MessagePackSerializer.Create(Type.GetType(this.typeName)); // Unpack the message's data object this.dataObject = (MessageBase)ser.UnpackSingleObject(temp); }