@@ -409,15 +409,18 @@ constructor TIocRegistrator.Create;
409409
410410destructor TIocRegistrator.Destroy;
411411var
412- reg : TIocRegistration;
412+ i : Integer;
413+ regs : TArray<TIocRegistration>;
413414begin
414- for regin fDependencies.Valuesdo
415+ // for reg in fDependencies.Values do
416+ regs := fDependencies.Values.ToArray;
417+ for i := High(regs)downto Low(regs)do
415418begin
416- if reg <>nil then
419+ if regs[i] <>nil then
417420begin
418421// free singleton instances not interfaced
419- if (reg is TIocRegistrationInstance)and (TIocRegistrationInstance(reg ).IsSingleton)then TIocRegistrationInstance(reg ).Instance.Free;
420- reg .Free;
422+ if (regs[i] is TIocRegistrationInstance)and (TIocRegistrationInstance(regs[i] ).IsSingleton)then TIocRegistrationInstance(regs[i] ).Instance.Free;
423+ regs[i] .Free;
421424end ;
422425end ;
423426 fDependencies.Free;
@@ -670,15 +673,12 @@ function TIocResolver.ResolveAll<T>(const aName : string = '') : TList<T>;
670673var
671674 pInfo : PTypeInfo;
672675 reg : TIocRegistration;
673- pair : TPair<string,TIocRegistration>;
674676begin
675677 Result := TList<T>.Create;
676678 pInfo := TypeInfo(T);
677679
678- for pair in fRegistrator.Dependencies.ToArray do
680+ for reg in fRegistrator.Dependencies.Values do
679681begin
680- reg := pair.Value ;
681- // var a := pair.Key;
682682if reg.IntfInfo = pInfothen Self.Resolve(pInfo,aName);
683683end ;
684684end ;