public PacketBuilder AddMessage(IMessage message) { var envelope = PacketMessageEnvelopeFactory.CreateEnvelope(_serializer, message); envelope.Metadata.MessageTag = _typeToTagResolver(message.GetType());; _envelopes.Add(envelope); return(this); }
/// <summary> /// Dangerous method for adding new message, because we unable to check correct state of MessageTag. /// To check this we should deserialize message. For performance reason we are avoiding this. /// Here we just checking that metadata has MessageTag specified. /// </summary> public PacketBuilder AddMessage(byte[] message, IMessageMetadata metadata) { var envelope = PacketMessageEnvelopeFactory.CreateEnvelope(_serializer, message, metadata); if (metadata.MessageTag == default(Guid)) { throw new Exception("Message tag not specified"); } _envelopes.Add(envelope); return(this); }