Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notify Changes on external parameter change

I need to attach a notify change event to an encapsulated parameter in an external class. I usually would implement INotifyPropertyChanged, but I can't edit the external class. What is the right approach for this problem?

like image 660
Hippity Avatar asked Aug 12 '14 08:08

Hippity


1 Answers

That will be very hard to do. The best option seems to be deriving that class, but you need all properties to be marked virtual. When you have no control over the class that seems to be unlikely.

If you are the only one calling that class, you could also create a wrapper that mimics that class' behavior. You could create properties yourself and implement INotifyPropertyChanged. You can't get notified on changed to the inner object though.

If that is your best option, you could also implement a implicit conversion operator so you can pass in your class like it was the class you are wrapping.

like image 109
Patrick Hofman Avatar answered Oct 07 '22 03:10

Patrick Hofman