TForEachBillpos =
procedure(billpos: IInicBillpos)
of object;
TForEachBillposProduct =
procedure(billposProduct: IInicBillposProduct)
of object;
procedure forEachBillpos(billing: IInicBilling; proc: TForEachBillpos);
procedure forEachBillposProduct(billing: IInicBilling; proc: TForEachBillposProduct);
overload;
procedure forEachBillposProduct(billpos: IInicBillpos; proc: TForEachBillposProduct);
overload;
function _getForEachBillposMethod(self: TObject; proc: Pointer): TForEachBillpos;
function _getForEachBillposProductMethod(self: TObject; proc: Pointer): TForEachBillposProduct;
[...]
procedure forEachBillpos(billing: IInicBilling; proc: TForEachBillpos);
var
it: IJclIntfIterator;
begin
it := billing.Billposes.Values.First;
while it.HasNext
do
proc(it.Next
as IInicBillpos);
// <----- OK
end;
procedure forEachBillposProduct(billing: IInicBilling; proc: TForEachBillposProduct);
procedure forEach(Self: pointer; billpos: IInicBillpos);
begin
forEachBillposProduct(billpos, proc);
end;
begin
forEachBillpos(billing, _getForEachBillposMethod(
nil, @forEach));
end;
procedure forEachBillposProduct(billpos: IInicBillpos; proc: TForEachBillposProduct);
var
it: IJclIntfIterator;
begin
it := billpos.BillposProducts.Values.First;
while it.HasNext
do
proc(it.Next
as IInicBillposProduct);
// <----- ACCESS VIOLATION
end;
function _getForEachBillposMethod(self: TObject; proc: Pointer): TForEachBillpos;
begin
TMethod(Result).Code := proc;
TMethod(Result).Data := self;
end;
function _getForEachBillposProductMethod(self: TObject; proc: Pointer): TForEachBillposProduct;
begin
TMethod(Result).Code := proc;
TMethod(Result).Data := self;
end;