Tuesday, August 2, 2011

Musings on using Unity Interception to achieve automatic INotifyPropertyChanged

I was just about to look at using Unity to implement automatic INotifyPropertyChanged. I've been meaning to do it ever since I heard the latest version of Unity for Silverlight supported method interception. It has just dawned on me however, that I might want to look again for a better option because (and I could be wrong) but using method interception will cause me one nasty little problem.

So, Unity will do a good job with something like this:


var x = container.Resolve<IMyInterface>();
x.PropertyOne = "This will work";



But what about this code?


public void SomeMethod()
{
this.PropertyOne = "I don't think this will work";
}



What am I going on about here? In a nutshell, the change notification won't happen when setting property values from within the object itself, since internally it isn't going through Unity.

I've only thought about it for a few minutes... But I think the workaround for this won't be terribly nice... and I've just seen a posting about this project, so I think I'll go check it out first.

No comments:

Post a Comment