A long time ago, I saw something that allowed you to chain a series of methods together dynamically. Can’t remember if it was in C#, or C++.
It goes something like this:
Methods:
Foo();
Bar();
Moar();
An object is then created that subscribes (for lack of a better word) to any or all of the methods above (depending on the programmer’s specification), and whatever is passed into this object will run through all the subscribed methods.
I ask, because I am working on a kernel for a program, which depending on a variety of choices, may or may not need certain methods. Since this program needs to be very tightly coded (I prefer not to waste a processor cycle on an if / else statement…it will add up), I was wondering if anyone recalls what I am attempting to convey, and what the C# equivalent would be.
Thanks,
-R
It sounds like an event:
declared:
subscribed:
then invoked:
which would invoke all the 3 methods, but with loose coupling.
Note you can do exactly the same just with a delagate rather than an event. Note also that events generally have a more specific
void (object sender, SomeEventArgs args)signature (but this is convention, not a requirement).