#1 2018-07-05 18:24:05

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

Dependency injection Propagation

Is there any way to access dependency resolution on an object that has been resolved as a dependency?

In other words, the "resolver" to be passed at constructor of the injected objects.

  IInjectedTestA = interface(IInvokable)
    ['{F06677DE-8781-479B-B40E-92B96E46799E}']
    procedure TestA;
  end;

  IInjectedTestB = interface(IInvokable)
    ['{0FA0367B-67F7-45E2-9BDC-8DF14558C580}']
    procedure TestBCallTestA;
  end;

  TInjectedTestA = class(TInterfacedObject, IInjectedTestA)
  public
    procedure TestA;
  end;

  TInjectedTestB = class(TInterfacedObject, IInjectedTestB)
  public
    procedure TestB;
    procedure TestBCallTestA;
  end;
procedure TInjectedTestB.TestB;
begin
  ShowMessage('TestB');
end;

procedure TInjectedTestB.TestBCallTestA;
var
  AInjected : IInjectedTestA;
begin
  Resolve(TypeInfo(IInjectedTestA), AInjected); //<<< Are one Way to this?
  AInjected.TestA.
end;

Offline

#2 2018-07-06 01:33:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Dependency injection Propagation

Offline

#3 2018-07-06 13:27:52

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

Re: Dependency injection Propagation

Thanks, for reply.

I are using this classes.

I thought there was some way to access the resolver (inside of an resolved object) without using RegisterGlobal.

Last edited by macfly (2018-07-06 13:28:48)

Offline

Board footer

Powered by FluxBB