c# - How to manipulate at runtime the invocation list of a Delegate? -
I want to know how to remove individual representatives from the list of my parents' representatives.
<> pre & lt; DelegateName & gt; .RemoveAll ();
Now I can only remove everyone and this will work only to get ideas in motion and see what should work, but then add deleted representatives again on runtime would be required!
Like this: ...
foreach (in the Delgate D & lt; representative & gt; invest in list) {// Do something with 'D'? ? }
Now that I have access to 'D' then I can leave it in one. Remove () but it requires two arguments ??? Can I get some help about this?
Finally, once the representative has been removed, what is the best way to add it again? So I'm assuming that reflection can play a part in this, but you can be above people.
Update:
Originally a global representative in which events living in many different humble classes, which are examples of these, all these events include a handler Which removes the event when it is removed. Controls all types of delegates at the top that all handlers matching the signature are removed. I want to mess about this representative at the top, I want to remove all the handlers and then add them to run time. Therefore the representative on top is a multicast representative and its announcement list is a list of different representatives, which in turn points to one of the four I have added. I hope this makes sense, that's a common idea of what I am doing.
You can not - delegates are irreversible You can create a new representative without any specific action Old is the equivalent, but you can not modify the existing one.
Comments
Post a Comment