This is a sample solution for showing different ways of using nvents.
Demonstrates the easiest way to subscribe to events using
Events.Subscribe<MyEvent>(e => ..) see Chat.Client-Subscribe/MainWindow.xaml.cs.
Demonstrates the usage of event handlers by implementing
IHandler<TEvent>. Two handlers are used Chat.Client-Handler/Handlers/MessageSentHandler.cs and Chat.Client-Handler/Handlers/UserKickedHandler.cs and they are registered by calling
Events.RegisterHandler(handler) in Chat.Client-Handler/MainWindow.xaml.cs.
Demonstrates the usage of standard .NET event registration by creating a new
EventSubscription<MyEvent> and attaching to it's
Published event see Chat.Client-EventSubscription/MainWindow.xaml.cs.
A more complete example using event handlers and the
IPublisher interface. Also demonstrating IoC (Ninject) and MVVM (Caliburn.Micro) with nvents.
The event handler Chat.Moderator/Handlers/MessageSentHandler.cs is registered in Chat.Moderator/NventsModule.cs which also binds the
IPublisher interface to the default nvents service.
IPublisher is used in Chat.Moderator/ViewModels/ShellViewModel.cs to publish
Test that the event is published by stubbing, mocking or faking
IPublisher and asserting that
Publish was called as shown in Chat.Moderator.Tests/ViewModels/ShellViewModelTests.cs.
Test that the event is subscribed to by stubbing, mocking or faking
Events.Service and asserting that
Subscribe was called as shown in Chat.Moderator.Tests/NventsModuleTests.cs.
MessageSent events and the
nvents - an open source library for strongly typed publishing/subscribing of events over the network.