本文整理汇总了C#中MessageHeaders.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# MessageHeaders.ContainsKey方法的具体用法?C# MessageHeaders.ContainsKey怎么用?C# MessageHeaders.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageHeaders
的用法示例。
在下文中一共展示了MessageHeaders.ContainsKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromHeaders
public void FromHeaders(MessageHeaders headers, Apache.NMS.IMessage nmsMessage)
{
try
{
if (headers.ContainsKey(NmsHeaders.CORRELATION_ID))
{
object nmsCorrelationId = headers[NmsHeaders.CORRELATION_ID] as string;
if (nmsCorrelationId != null)
{
nmsMessage.NMSCorrelationID = (string) nmsCorrelationId;
}
}
if (headers.ContainsKey(NmsHeaders.REPLY_TO))
{
object nmsReplyTo = headers[NmsHeaders.REPLY_TO] as IDestination;
if (nmsReplyTo != null)
{
nmsMessage.NMSReplyTo = (IDestination) nmsReplyTo;
}
}
if (headers.ContainsKey(NmsHeaders.TYPE))
{
object nmsType = headers[NmsHeaders.TYPE] as string;
if (nmsType != null)
{
nmsMessage.NMSType = (string) nmsType;
}
}
ICollection<string> attributeNames = headers.Keys;
foreach (string attributeName in attributeNames)
{
if (!attributeName.StartsWith(NmsHeaders.PREFIX))
{
if (StringUtils.HasText(attributeName))
{
object val = headers[attributeName];
if (val != null && IsValidPropertyType(val))
{
try
{
nmsMessage.Properties[attributeName] = val;
}
catch (Exception ex)
{
if (logger.IsWarnEnabled)
{
logger.Warn("failed to map Message header '"
+ attributeName + "' to NMS property", ex);
}
}
}
}
}
}
} catch (Exception ex)
{
if (logger.IsWarnEnabled)
{
logger.Warn("error occurred while mapping properties from MessageHeaders", ex);
}
}
}