本文整理汇总了C#中ISession.CreateMapMessage方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.CreateMapMessage方法的具体用法?C# ISession.CreateMapMessage怎么用?C# ISession.CreateMapMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISession
的用法示例。
在下文中一共展示了ISession.CreateMapMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToMessage
public override IMessage ToMessage(object objectToConvert, ISession session)
{
Trade trade = objectToConvert as Trade;
if (trade == null)
{
throw new MessageConversionException("TradeConverter can not convert object of type " +
objectToConvert.GetType());
}
try
{
IMapMessage mm = session.CreateMapMessage();
mm.Body.SetString("orderType", trade.OrderType);
mm.Body.SetDouble("price", trade.Price);
mm.Body.SetLong("quantity", trade.Quantity);
mm.Body.SetString("ticker", trade.Ticker);
return mm;
}
catch (Exception e)
{
throw new MessageConversionException("Could not convert TradeRequest to message", e);
}
}
示例2: ToMessage
public override IMessage ToMessage(object objectToConvert, ISession session)
{
TradeRequest tradeRequest = objectToConvert as TradeRequest;
if (tradeRequest == null)
{
throw new MessageConversionException("TradeRequestConverter can not convert object of type " +
objectToConvert.GetType());
}
try
{
IMapMessage mm = session.CreateMapMessage();
mm.Body.SetString("accountName", tradeRequest.AccountName);
mm.Body.SetBool("buyRequest", tradeRequest.BuyRequest);
mm.Body.SetString("orderType", tradeRequest.OrderType);
mm.Body.SetDouble("price", tradeRequest.Price);
mm.Body.SetLong("quantity", tradeRequest.Quantity);
mm.Body.SetString("requestId", tradeRequest.RequestId);
mm.Body.SetString("ticker", tradeRequest.Ticker);
mm.Body.SetString("username", tradeRequest.UserName);
return mm;
} catch (Exception e)
{
throw new MessageConversionException("Could not convert TradeRequest to message", e);
}
}
示例3: CreateMessageForMap
/// <summary> Create a NMS IMapMessage for the given Map.</summary>
/// <param name="map">the Map to convert
/// </param>
/// <param name="session">current NMS session
/// </param>
/// <returns> the resulting message
/// </returns>
/// <throws> NMSException if thrown by NMS methods </throws>
protected virtual IMapMessage CreateMessageForMap(IDictionary map, ISession session)
{
IMapMessage mapMessage = session.CreateMapMessage();
foreach (DictionaryEntry entry in map)
{
if (!(entry.Key is string))
{
//UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
throw new MessageConversionException("Cannot convert non-String key of type [" +
(entry.Key != null ? entry.Key.GetType().FullName : null) +
"] to IMapMessage entry");
}
mapMessage.Body[entry.Key.ToString()] = entry.Value;
}
return mapMessage;
}
示例4: CreateMessageForMap
/// <summary> Create a EMS MapMessage for the given Map.</summary>
/// <param name="map">the Map to convert
/// </param>
/// <param name="session">current EMS session
/// </param>
/// <returns> the resulting message
/// </returns>
/// <throws> EMSException if thrown by EMS methods </throws>
protected virtual MapMessage CreateMessageForMap(IDictionary map, ISession session)
{
MapMessage mapMessage = session.CreateMapMessage();
foreach (DictionaryEntry entry in map)
{
if (!(entry.Key is string))
{
throw new MessageConversionException("Cannot convert non-String key of type [" +
(entry.Key != null ? entry.Key.GetType().FullName : null) +
"] to MapMessage entry");
}
mapMessage.SetObject(entry.Key.ToString(), entry.Value);
}
return mapMessage;
}