set {Looking at CSLA3.5Beta 2 it would appear that this is not possible if using:
if(_field1 != value){
_field1 = value;
_field2 = field1 / 2;
RecalculateSomething();
PropertyHasChanged();
}
set { SetProperty<double>(Field1Property, value); }So I propose overloading SetProperty to allow a callback delegate to be passed in:
protected void SetPropertyCallback();And modify BusinessBase.LoadPropertyValue<P>():
protected void SetProperty<P>(PropertyInfo<P> propertyInfo, P newValue, SetPropertyCallback setPropertyCallback);
if (markDirty) {(I also propose refactoring the instances where the above code appears into a single private function).
OnPropertyChanging(propertyInfo.Name);
FieldManager.SetFieldData<P>(propertyInfo, newValue);
if(setPropertyCallback!= null)
setPropertyCallback();
PropertyHasChanged(propertyInfo.Name);
}
set { SetProperty<double>(Field1Property, value, delegate {RecalculateSomething();} ); }Any thoughts on this?
If your using managed fields, it's possible to call one of the protected overloads of LoadProperty. These overloads do not call PropertyHasChanged. So, you can set your fields using a call to LoadProperty for each field and then call PropertyHasChanged. The LoadProperty methods do not automatically do any authorization checking, so you might also need to make a call to CanWriteProperty.
The LoadProperty overloads call the private LoadPropertyValue method with the last parameter, markDirty, equal to false, which prevents the call to PropertyHasChanged. I haven't actually run any code to test what I suggested, so maybe I'm missing something else.
damo:Rocky suggested that I create a rule to perform the calculation, but to me, that doesn't seem right - they are called ValidationRules...
Copyright (c) Marimer LLC