当前位置: 首页>>代码示例>>C#>>正文


C# ISession.CreateMapMessage方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:fgq841103,项目名称:spring-net,代码行数:25,代码来源:TradeConverter.cs

示例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);
            }
        }
开发者ID:Binodesk,项目名称:spring-net,代码行数:30,代码来源:TradeRequestConverter.cs

示例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;
 }
开发者ID:ouyangyl,项目名称:MySpringNet,代码行数:24,代码来源:SimpleMessageConverter.cs

示例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;
 }
开发者ID:Binodesk,项目名称:spring-net,代码行数:23,代码来源:SimpleMessageConverter.cs


注:本文中的ISession.CreateMapMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。