-
Notifications
You must be signed in to change notification settings - Fork 649
/
IncomingMessageExtensions.cs
39 lines (35 loc) · 1.31 KB
/
IncomingMessageExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
namespace NServiceBus.Transport
{
using System;
/// <summary>
/// Helper methods for <see cref="IncomingMessage" />.
/// </summary>
public static class IncomingMessageExtensions
{
/// <summary>
/// Gets the message intent from the headers.
/// </summary>
/// <param name="message">The message.</param>
/// <returns>The message intent.</returns>
public static MessageIntent GetMessageIntent(this IncomingMessage message)
{
Guard.AgainstNull(nameof(message), message);
var messageIntent = default(MessageIntent);
if (message.Headers.TryGetValue(Headers.MessageIntent, out var messageIntentString))
{
Enum.TryParse(messageIntentString, true, out messageIntent);
}
return messageIntent;
}
/// <summary>
/// Gets the reply to address.
/// </summary>
/// <param name="message">The message.</param>
/// <returns>The reply to address.</returns>
public static string GetReplyToAddress(this IncomingMessage message)
{
Guard.AgainstNull(nameof(message), message);
return message.Headers.TryGetValue(Headers.ReplyToAddress, out var replyToAddress) ? replyToAddress : null;
}
}
}