upta/pubsub — pull request #2 by wki (2014-05-01 09:24:08+00:00)
Title: hierarchical event classes

Hi,

I am currently planning to create a small .NET based app using Domain-Driven-Design and want to use a simple pubsub library for decoupling all my classes. Your pubsub is exactly what I am looking for except that a consumer must explicitly subscribe the event-classes he wants. If you are in a situation where you like to forward certain events to an external message Queue or if you like to log _all_ events, you are in trouble.

If you consider Events like this:

interface IForward {}
class Event {}
class MyEvent : Event {}
class AnotherEvent :Event :IForward {}

Then you might Subscribe(...) in order to catch all events based on the Event class in a single line instead of listing all of them. Another interesting scenario might be to "decorate" certain event classes with an interface of a meaningful name in order to have some kind of filtering. Subscribe(...) would catch all events decorated with IForward.

The change in source code is minimal, tests include inheritance tests which I personally think are sufficient. If you like the Idea I could add some examples for the README.

Best, Wolfgang

PS: I had some trouble using the PubSub.csproj file, therefore the file is different from yours. I am using the Express version of Visual-Studio 2013. If there is a trick would be nice to know :-)