For each setter of a class I have to implement some event logic (OnChanging, OnChanged):
procedure TBlock.SetWeightIn(const Value: Double);
var OldValue: Double;
begin
OldValue := FWeightIn;
DoOnChanging(OldValue, Value);
FWeightIn := Value;
DoOnChanged(OldValue, Value);
end;
procedure TBlock.SetWeightOut(const Value: Double);
var OldValue: Double;
begin
OldValue := FWeightOut;
DoOnChanging(OldValue, Value);
FWeightOut := Value;
DoOnChanged(OldValue, Value);
end;
Can you please suggest a way to implement this without duplicating all these lines for each setter?