Get compiler generated delegate for an event

Posted by Sandor Davidhazi on Stack Overflow See other posts from Stack Overflow or by Sandor Davidhazi
Published on 2010-04-08T09:02:48Z Indexed on 2010/04/08 9:13 UTC
Read the original article Hit count: 433

I need to know what handlers are subsribed to the CollectionChanged event of the ObservableCollection class. The only solution I found would be to use Delegate.GetInvocationList() on the delegate of the event. The problem is, I can't get Reflection to find the compiler generated delegate. AFAIK the delegate has the same name as the event. I used the following piece of code:

PropertyInfo notifyCollectionChangedDelegate = collection.GetType().GetProperty("CollectionChanged", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);

© Stack Overflow or respective owner

Related posts about c#

Related posts about delegates