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


C# IMessageBus.Send方法代码示例

本文整理汇总了C#中IMessageBus.Send方法的典型用法代码示例。如果您正苦于以下问题:C# IMessageBus.Send方法的具体用法?C# IMessageBus.Send怎么用?C# IMessageBus.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMessageBus的用法示例。


在下文中一共展示了IMessageBus.Send方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendOperation1

        public static void SendOperation1(IMessageBus bus, IDbConnection conn, int i)
        {
            using (IDbCommand cmd = conn.CreateCommand())
            {
            cmd.CommandText = string.Format("select id, name from test where id={0}", i);
            string name;
            using (IDataReader dr = cmd.ExecuteReader())
            {
            dr.Read();
            name = dr.GetString(1);
            }
            cmd.CommandText = string.Format("update Test set name='{1}' where id={0}", i, DateTime.Now.ToString());
            cmd.ExecuteNonQuery();

            bus.Send("sql://testdb1/MQueue2", new TestMessage1 { Id = i });

            cmd.CommandText = string.Format("insert into TestLog (tstamp, user_id, summary) values(getdate(), 'I', 'send operation {0}')", i);
            cmd.ExecuteNonQuery();

            bus.Send("sql://testdb1/MQueue2", new TestMessage2 { Text = "first " + i });
            bus.Send("sql://testdb1/MQueue2", new TestMessage2 { Text = "second " + i });
            }
        }
开发者ID:BrettBailey,项目名称:nginn-messagebus,代码行数:23,代码来源:PerfTest.cs

示例2: AttachParser

        private void AttachParser(IMessageBus messageBus, IObservable<DataReceivedMessage> myMessages)
        {
            //send typed ping message
            myMessages
               .Select(m => Patterns.PingRegex.Match(m.Data))
               .Where(f => f.Success)
               .Select(f => new IrcPingMessage { Connection = this, ServerName = f.Groups[1].Value, })
               .Do(m => messageBus.Send(m))
               .Subscribe();

            //send typed notice message
            myMessages
               .Select(m => Patterns.NoticeRegex.Match(m.Data))
               .Where(f => f.Success)
               .Select(f => new IrcNoticeMessage { Connection = this, Message = f.Groups[2].Value, })
               .Do(m => messageBus.Send(m))
               .Subscribe();

            //send typed reply message
            myMessages
               .Select(m => Patterns.ReplyCodeRegex.Match(m.Data))
               .Where(f => f.Success)
               .Select(f => new IrcReplyCodeMessage { Connection = this, Message = f.Groups[2].Value,Code=int.Parse(f.Groups[1].Value) })
               .Do(m => messageBus.Send(m))
               .Subscribe();

            //send typed error message
            myMessages
               .Select(m => Patterns.ErrorRegex.Match(m.Data))
               .Where(f => f.Success)
               .Select(f => new IrcErrorMessage { Connection = this, Message = f.Value, })
               .Do(m => messageBus.Send(m))
               .Subscribe();

            //send typed Mode message
            myMessages
               .Select(m => Patterns.ModeRegex.Match(m.Data))
               .Where(f => f.Success)
               .Select(f => new IrcModeMessage { Connection = this, Message = f.Value, })
               .Do(m => messageBus.Send(m))
               .Subscribe();
            
            //send typed join message
            myMessages
               .Select(m => Patterns.JoinRegex.Match(m.Data))
               .Where(f => f.Success)
               .Select(f => new IrcJoinMessage 
               { 
                   Connection = this, 
                   User = f.Groups[1].Value,
                   UserIdentity = f.Groups[2].Value,
                   Channel = f.Groups[3].Value.ToUpperInvariant(),
               })
               .Do(m => messageBus.Send(m))
               .Subscribe();

            //send typed part message
            myMessages
               .Select(m => Patterns.PartRegex.Match(m.Data))
               .Where(f => f.Success)
               .Select(f => new IrcPartMessage
               {
                   Connection = this,
                   User = f.Groups[1].Value,
                   UserIdentity = f.Groups[2].Value,
                   Channel = f.Groups[3].Value.ToUpperInvariant()
               })
               .Do(m => messageBus.Send(m))
               .Subscribe();

            //send typed part message
            myMessages
               .Select(m => Patterns.QuitRegex.Match(m.Data))
               .Where(f => f.Success)
               .Select(f => new IrcQuitMessage
               {
                   Connection = this,
                   User = f.Groups[1].Value,
                   UserIdentity = f.Groups[2].Value,
               })
               .Do(m => messageBus.Send(m))
               .Subscribe();

            //send typed channel message
            myMessages
               .Select(m => Patterns.MessageRegex.Match(m.Data))
               .Where(f => f.Success)
               .Where(f => f.Groups[3].Value.StartsWith("#"))
               .Select(f => new IrcChannelSayMessage 
               { 
                   Connection = this,
                   User = f.Groups[1].Value,
                   UserIdentity=f.Groups[2].Value,
                   Channel = f.Groups[3].Value.ToUpperInvariant(),
                   Message=f.Groups[4].Value }
               )
               .Do(m => messageBus.Send(m))
               .Subscribe();

            //send typed private message
//.........这里部分代码省略.........
开发者ID:attila3453,项目名称:alsing,代码行数:101,代码来源:IrcConnection.cs


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