so for instance I have a main form and want to inject a logger instance as private field.
I register the logger
GlobalContainer.RegisterType<TCNHInMemoryLogger>.Implements<ILogger>;
I have a private field in my main form
private
FLogger: ILogger;
All what I want is to make so:
private
[Inject]
FLogger: ILogger;
In my DPR file I have typical delphi way to create main form:
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(Tfrm_CNH, frm_CNH);
Application.Run;
end.
What should I change in a way of the form creation to have private fields injected properly?
By the way if I resolve the field in Form.OnCreate with GlobalContainer.Resolve it works fine. But I want to avoid using GlobalContainer variable in my forms.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…