In CSLA 3.8 I was maintaining a list of dirty properties by overriding the OnPropertyChanged event and adding the propertyname to an internal list of strings if it didn't already exist. Then I would clear that list in an override of MarkOld. This worked without any issue in 3.8.
But now in 4.3 the OnPropertyChanged event seems to be working differently with the new Rules system. In 3.8 I would change a property, and I would get a single OnPropertyChanged event thrown for that property. But in 4.2 it is also throwing the OnPropertyChanged for each dependent property of the property I changed. As a result, my dirty properties list contains a bunch of properties in it that aren't actually dirty because they were never changed.
Further, there are 2 OnPropertyChanged methods, one with a string parameter and one with a propertyinfo parameter. I've tried both of them and while the string parameter method would be thrown for the changed property and all it's dependent properties, the propertyinfo parameter method wasn't being thrown at all.
So my question is, what should I now be doing to keep track of a dirty properties list in 4.3? Should I be using another method altogether?
Here is my code in my base class right now that is being thrown for the changed property and its dependencies:
Public Shared ReadOnly DirtyPropertiesProperty As PropertyInfo(Of Collection(Of String)) = RegisterProperty(Of Collection(Of String))(Function(obj As MyBusinessBase(Of T)) obj.DirtyProperties, "Dirty Properties", New Collection(Of String)) ''' <summary> ''' A collection of the properties that have been changed ''' </summary> Public Property DirtyProperties() As Collection(Of String) Get Return GetProperty(DirtyPropertiesProperty) End Get Set(ByVal value As Collection(Of String)) SetProperty(DirtyPropertiesProperty, value) End Set End Property
Protected Overrides Sub OnPropertyChanged(ByVal propertyName As String) MyBase.OnPropertyChanged(propertyName) ' Add the property to the list of dirty properties If Not ReadProperty(DirtyPropertiesProperty).Contains(propertyName) Then ReadProperty(DirtyPropertiesProperty).Add(propertyName) End If End Sub
Protected Overrides Sub MarkOld() MyBase.MarkOld() ' clear all dirty properties ReadProperty(DirtyPropertiesProperty).Clear() End Sub
Any help would be greatly appreciated.
Thanks,
Mike