本文整理汇总了C#中MessageHandler.WireToLambda方法的典型用法代码示例。如果您正苦于以下问题:C# MessageHandler.WireToLambda方法的具体用法?C# MessageHandler.WireToLambda怎么用?C# MessageHandler.WireToLambda使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageHandler
的用法示例。
在下文中一共展示了MessageHandler.WireToLambda方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run_in_test
public void Run_in_test()
{
var streamer = EnvelopeStreamer.CreateDefault(typeof(CreateCustomer), typeof(CustomerCreated));
var builder = new CqrsEngineBuilder(streamer);
var account = new MemoryAccount();
var nuclear = account.CreateNuclear();
var inbox = account.CreateInbox("input");
var sender = account.CreateSimpleSender(streamer, "input");
var handler = new MessageHandler();
handler.WireToLambda<CreateCustomer>(customer => Consume(customer, nuclear, sender));
handler.WireToLambda<CustomerCreated>(m => Console.WriteLine("Created!"));
builder.Handle(inbox, handler.HandleEnvelope);
using (var engine = builder.Build())
{
sender.SendOne(new CreateCustomer
{
CustomerId = 1,
CustomerName = "Rinat Abdullin"
});
engine.RunForever();
}
}
示例2: Setup
public void Setup()
{
//
// observers
SystemObserver.Setup(new IObserver<ISystemEvent>[] { new ConsoleObserver() });
//
// message handlers
var handler = new MessageHandler();
handler.WireToLambda<CreateAccount>(new CreateAccountHandler().Handle);
handler.WireToLambda<AccountCreated>(new AccountCreatedHandler().Handle);
//
// message router
var router = new MemoryMessageRouter();
m_router = router;
m_registerRoutes = router;
m_registerRoutes.RegisterHandler<CreateAccount>(handler.Handle);
m_registerRoutes.RegisterHandler<AccountCreated>(handler.Handle);
//
// message bus
var bus = new MemoryBusWithRouter(m_router);
//
// Queue Writer
var queueWriter = new QueueWriterToBus(bus);
//
// Misc
m_sender = new MessageSender(new IQueueWriter[] { queueWriter });
m_id = new AccountID(Guid.NewGuid());
}
示例3: event_handler_should_handle_event
public void event_handler_should_handle_event()
{
// arrange
var e = new AccountCreated(m_id);
var handler = new MessageHandler();
handler.WireToLambda<AccountCreated>(new AccountCreatedHandler().Handle);
// act
handler.Handle(e);
// assert
}