Rhino Mocks EventsTwisting the Syntax

time to read 1 min | 172 words

Okay, so Aaron Jensen has suggest an alternative syntax to this (which I don't like, since it has strings):

IEventRaiser loadRaiser = new EventRaiser((IMockedObject)mockedView, "Load");

It is this:

obj.Bar += EventRaiser.Raise(this, EventArgs.Empty);

Basically, it is reversing the syntax a bit, since it is actually the "register to event" syntax, but we can use that to raise events in a fairly natural way, without resorting to strings.

I am not sure if the sytnax is clear enough, so I wanted to ask, what would you rather have?

More posts in "Rhino Mocks Events" series:

  1. (09 Jun 2007) Twisting the Syntax
  2. (08 Jun 2007) Purity vs. Practicality