/// <summary> /// Customize how a message of this type is sent by modifying /// the outgoing Envelope /// </summary> /// <param name="customization"></param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public MessageTrackExpression Customize(Action <Envelope> customization) { var rule = new MessageTypeRule(type => _routing.Matches(type), customization); _bus.Settings.MessageTypeRules.Add(rule); return(this); }
public void apply_message_rules() { var rule1 = new MessageTypeRule(t => t == typeof(MySpecialMessage), e => e.Headers.Add("rule1", "true")); var rule2 = new MessageTypeRule(t => t.IsInNamespace(typeof(MySpecialMessage).Namespace), e => e.Headers.Add("rule2", "true")); var settings = new MessagingSettings(); settings.MessageTypeRules.Add(rule1); settings.MessageTypeRules.Add(rule2); var envelope = new Envelope { Message = new MySpecialMessage() }; settings.ApplyMessageTypeSpecificRules(envelope); envelope.Headers["rule1"].ShouldBe("true"); envelope.Headers["rule2"].ShouldBe("true"); }