OnPropertyChanged with property info parameter

OnPropertyChanged with property info parameter

Old forum URL: forums.lhotka.net/forums/t/6687.aspx


jureleskovec posted on Friday, March 27, 2009

Why is there no 'OnPropertyChanged' overload accepting a property info object or lambda expresion? We still have to use literal strings which are quite dangerous.

-- Jure

JoeFallon1 replied on Friday, March 27, 2009

You do not have to use the literal string.
Just use propertyInfo.Name instead.

Joe

RockfordLhotka replied on Friday, March 27, 2009

Accepting a lambda expression would be a performance issue. There's no magic to how that "c=>c.Name" works, it just uses reflection to take the lambda apart and pull out the property name - and reflection is slow.

But having an overload that accepts a PropertyInfo<T> is not a bad idea.

You must realize however, that the PropertyChanged event is defined by Microsoft and data binding, and it only works with the string property name... So regardless of what I do in CSLA, the end result is always a string value :)

Copyright (c) Marimer LLC