I use events as part of the game model, and for the extension and the "terrain" code, I should be able to veto most actions.
More clearly, almost every method with a side effect takes the following form:
public event TryingToDoSomethingHandler TryingToDoSomething;
public event SomethingHappenedHandler SomethingHappened;
public bool DoSomething(...)
{
TryingToDoSomething(...);
SomethingHappened(...);
return true;
}
I would like to try TryingToDoSomething (...) to indicate that the registered object is an event handler (via returning false, changing the out parameter or something else). To make the code morally equivalent:
public bool DoSomethingImproved(...)
{
if(!TryingToDoSomething(...)) return false;
SomethingHappened(...);
return true;
}
Is there an acceptable or standard way to do this in C # /. NET?
source
share