简体   繁体   中英

Get Event Subscriptions with Reflection

I'm trying to loop through all event subscriptions for an object that : INotifyPropertyChanged This is as far as I can get:

EventInfo e1 = typeof(INotifyPropertyChanged).GetEvent("PropertyChanged",
   BindingFlags.Instance | BindingFlags.Public);

Now how would I go about getting all subscriptions to that event for a given INotifyPropertyChanged object?

Thanks!

There isn't any simple way to create a generic solution for this since you have no way of knowing what the backing store for any given event might be. While attempting to infer the backing store is possible, it's not exactly a robust or low-cost solution. If you could share your end goal, it might be possible to suggest a more easily managed approach.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM