For debugging / performance tests I would like to dynamically add logging code to all event handlers of components of a given type at run time.
For example, for all
I would try this:
TDataSetBeforeOpenStartTimeStorer = class(TObject)
constructor Create(MyDataModule : TMyDatamodule);
begin
OldBeforeOpen := MyDatamodule.OnBeforeOpen;
MyDatamodule.OnBeforeOpen = NewBeforeOpen;
end;
procedure NewBeforeOpen(Sender: TDataset);
begin
StoreStartTime(Sender);
if Assigned(OldBeforeOpen) then
OldBeforeOpen(Sender);
end;
Attach one TDataSetBeforeOpenStartTimeStorer instance to every TDataSet and you'll have your functionality.