Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf9b4b24

Browse files
committed
[ioc] improved destroy services
1 parent2b85fb3 commitf9b4b24

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

‎Quick.IOC.pas‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,18 @@ constructor TIocRegistrator.Create;
409409

410410
destructor TIocRegistrator.Destroy;
411411
var
412-
reg : TIocRegistration;
412+
i : Integer;
413+
regs : TArray<TIocRegistration>;
413414
begin
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
415418
begin
416-
ifreg<>nilthen
419+
ifregs[i]<>nilthen
417420
begin
418421
//free singleton instances not interfaced
419-
if (regis 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;
421424
end;
422425
end;
423426
fDependencies.Free;
@@ -670,15 +673,12 @@ function TIocResolver.ResolveAll<T>(const aName : string = '') : TList<T>;
670673
var
671674
pInfo : PTypeInfo;
672675
reg : TIocRegistration;
673-
pair : TPair<string,TIocRegistration>;
674676
begin
675677
Result := TList<T>.Create;
676678
pInfo := TypeInfo(T);
677679

678-
forpairin fRegistrator.Dependencies.ToArraydo
680+
forregin fRegistrator.Dependencies.Valuesdo
679681
begin
680-
reg := pair.Value;
681-
//var a := pair.Key;
682682
if reg.IntfInfo = pInfothen Self.Resolve(pInfo,aName);
683683
end;
684684
end;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp