25 lines
798 B
C#
25 lines
798 B
C#
using Netmash.Infrastructure.Messaging.Constants;
|
|
using Netmash.Infrastructure.Messaging.Models;
|
|
|
|
namespace Netmash.Infrastructure.Messaging.Extensions
|
|
{
|
|
public static class MessagingEnvelopeExtensions
|
|
{
|
|
public static string GetMessageTypeId(this MessagingEnvelope envelope)
|
|
{
|
|
return envelope.Headers.TryGetValue(MessagingHeaders.MessageType, out var value)
|
|
? value
|
|
: null;
|
|
}
|
|
|
|
public static void SetHeader(this MessagingEnvelope envelope, string header, string value, bool overwrite = false)
|
|
{
|
|
if (!overwrite && envelope.Headers.ContainsKey(header) && !string.IsNullOrEmpty(envelope.Headers[header]))
|
|
return;
|
|
|
|
envelope.Headers[header] = value;
|
|
|
|
}
|
|
}
|
|
}
|