I am using events as a publisher/subscriber pattern in c#. However I dont know at design time how many publishers my program will be using. I would like to dynamically add events to either a class directly, or more plausibly to a collection/dictionary containing the events.
Are either of these scenarios possible using C#?
Create a mediator that your publishers publish to and that your subscribers subscribe to. For example:
Make sure you implement IDisposable on your subscriber (its not in my example) so that it unsubscribes from the Mediator during dispose.