本文整理汇总了C#中SerializableDictionary.SetXml方法的典型用法代码示例。如果您正苦于以下问题:C# SerializableDictionary.SetXml方法的具体用法?C# SerializableDictionary.SetXml怎么用?C# SerializableDictionary.SetXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializableDictionary
的用法示例。
在下文中一共展示了SerializableDictionary.SetXml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeserializeFromXml
public static TransportMessage DeserializeFromXml(OracleAQMessage message)
{
if (message == null)
{
return null;
}
XmlDocument bodyDoc;
using (OracleXmlType type = (OracleXmlType)message.Payload)
{
bodyDoc = type.GetXmlDocument();
}
var bodySection = bodyDoc.DocumentElement.SelectSingleNode("Body").FirstChild as XmlCDataSection;
var headerDictionary = new SerializableDictionary<string, string>();
var headerSection = bodyDoc.DocumentElement.SelectSingleNode("Headers");
if (headerSection != null)
{
headerDictionary.SetXml(headerSection.InnerXml);
}
Address replyToAddress = null;
var replyToAddressSection = bodyDoc.DocumentElement.SelectSingleNode("ReplyToAddress");
if (replyToAddressSection != null && !string.IsNullOrWhiteSpace(replyToAddressSection.InnerText))
{
replyToAddress = Address.Parse(replyToAddressSection.InnerText.Trim());
}
MessageIntentEnum messageIntent = default(MessageIntentEnum);
var messageIntentSection = bodyDoc.DocumentElement.SelectSingleNode("MessageIntent");
if (messageIntentSection != null)
{
messageIntent = (MessageIntentEnum)Enum.Parse(typeof(MessageIntentEnum), messageIntentSection.InnerText);
}
var transportMessage = new TransportMessage(new Guid(message.MessageId).ToString(), headerDictionary)
{
Body = bodySection != null ? Encoding.UTF8.GetBytes(bodySection.Data) : new byte[0],
ReplyToAddress = replyToAddress,
MessageIntent = messageIntent,
};
return transportMessage;
}
示例2: ExtractTransportMessage
private TransportMessage ExtractTransportMessage(object payload)
{
OracleXmlType type = (OracleXmlType)payload;
var bodyDoc = type.GetXmlDocument();
var bodySection = bodyDoc.DocumentElement.SelectSingleNode("Body").FirstChild as XmlCDataSection;
var headerDictionary = new SerializableDictionary<string, string>();
var headerSection = bodyDoc.DocumentElement.SelectSingleNode("Headers");
if (headerSection != null)
{
headerDictionary.SetXml(headerSection.InnerXml);
}
Address replyToAddress = Address.Undefined;
var replyToAddressSection = bodyDoc.DocumentElement.SelectSingleNode("ReplyToAddress");
if (replyToAddressSection != null)
{
replyToAddress = Address.Parse(replyToAddressSection.InnerText);
}
MessageIntentEnum messageIntent = default(MessageIntentEnum);
var messageIntentSection = bodyDoc.DocumentElement.SelectSingleNode("MessageIntent");
if (messageIntentSection != null)
{
messageIntent = (MessageIntentEnum)Enum.Parse(typeof(MessageIntentEnum), messageIntentSection.InnerText);
}
TransportMessage message = new TransportMessage
{
Body = Encoding.UTF8.GetBytes(bodySection.Data),
Headers = headerDictionary,
ReplyToAddress = replyToAddress,
MessageIntent = messageIntent,
};
return message;
}