本文整理汇总了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 });
}
}
示例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
//.........这里部分代码省略.........