Magic number (4) is account for the prefix "set " || "get " due to it being inside a property asscessor.
So, not really magic at all, just due to location of call.
As to simplifying for outside calling of a the PropertyChanged... Use expressions.
linq-expressions-and-extension-methods-to-get-property-name @ stackoverflow.com
I think the big thing that I don't like very much about your solution here is that it doesn't really remove maintenance concerns, it minimizes them some and centralizes them, but doesn't remove them completely.
Also you would have to use a magic number (4) so you still have the risk of setting the string range to an incorrect value (especially when using copy/paste). This isn't much better then the risk of a typo during entering the string.
As you said, yourself, Reflection in to slow; maybe it's not a wise idea to use it in big projects.
And there is another problem with this method: in your method we can't refactor the process of raising the event in a separate method (e.g. RaisePropertyChanged), because if so, the reflection will return the name of the method, itself.
I haven't ever taught of using reflection this way, thanks a lot for sharing your knowledge
Last Visit: 31-Dec-99 18:00 Last Update: 4-Aug-15 8:46