Spring Framework for Delphi (Spring4D for short) is an open-source code library targeting Delphi 2010 onward. It includes mostly a Dependency Injection Framework and a Base Class Library among other modules.
Questions tagged [spring4d]
144 questions
15
votes
2 answers
Delphi interface helpers / workarounds
I realise that Delphi does not support interface helpers, but after reading several SO topics and sources of Spring4D and so forth, I'm wondering is there is any way to achieve the following? The source code comments pretty much sums up what I'm…

Rick Wheeler
- 1,142
- 10
- 22
13
votes
1 answer
Constructor injection versus setter injection for Parent property
I'm trying to figure out the best way to use dependency injection for some legacy code which will take a long to refactor and has to be done gradually. Most of the old classes use a "Parent" property for determining various things and the parent…

Rick Wheeler
- 1,142
- 10
- 22
13
votes
0 answers
Spring 4D. Who is using this framework, what is your experience?
I have been coding with Delphi for a year now. I do however have much more experience with .NET. I am reading Nick Hodges book 'Coding In Delphi' where he introduces and endorses the Spring 4 Delphi framework.
I was immediately excited about the…

santiagoIT
- 9,411
- 6
- 46
- 57
10
votes
1 answer
IList crashes when T is an event handler?
It appears to me that IList can NOT take Event handler as its element. The program has access violation $C00000005 on PROGRAM exit.
Everything is fine if I use Delphi RTL's TList.
The access violation happens for both 32 bit and 64bit build. When…

Wuping Xin
- 120
- 5
9
votes
2 answers
delphi - how to pass a parameter from the instantiator to a constructor in the spring4d dependency injection framework?
It's possible to register a class with a parameter expected to be passed from the point of creation?
I know it can be done something like this:
GlobalContainer.RegisterType.Implements.
AsTransient.DelegateTo(
…

pragmatic_programmer
- 3,566
- 3
- 29
- 36
8
votes
5 answers
Why is list of type TObjectList freed automatically after iteration?
I have a question regarding the behaviour of the TObjectList class of the Spring4D framework. In my code I create a list of geometric figures such as square, circle, triange, each defined as an individual class. To free the geometric figures…

MUG4N
- 19,377
- 11
- 56
- 83
8
votes
2 answers
Delphi Spring DI: Is it possible to delegate interface instantiation without an implementing type?
I'm just getting started with the Delphi Spring Framework and was wondering whether the current version of the DI container somehow allows delegating the construction to a factory method without specifying an implementing type?
E.g. something…

Oliver Giesen
- 9,129
- 6
- 46
- 82
7
votes
2 answers
How do I ensure that a given dependency is included in my app with the Spring Framework?
This is going to be a tough question to describe, but here goes.
We are using the Delphi Spring Framework. (http://code.google.com/p/delphi-spring-framework/)
Let's say I have UnitA that declares InterfaceA which is implemented by ClassA.
Similarly,…

Nick Hodges
- 16,902
- 11
- 68
- 130
6
votes
4 answers
How to remove all duplicates from a list?
Consider this test app:
function RemoveDuplicates(const Input: IEnumerable): IEnumerable;
begin
// How to implement this function?
end;
var
Enumerable: IEnumerable;
UniqueEnumerable: IEnumerable;
begin
…

Jens Mühlenhoff
- 14,565
- 6
- 56
- 113
6
votes
1 answer
Is there a map function?
I just wrote this function:
class function TGenerics.Map(const AEnumerable: IEnumerable;
const AConverter: TConstFunc): IList;
var
L: IList;
begin
L := TCollections.CreateList;
…

Jens Mühlenhoff
- 14,565
- 6
- 56
- 113
5
votes
1 answer
Delphi, how to avoid application.CreateForm?
I am using Spring4d framework for dependency injection and other things.
In the application entry point, I have to create the application "Main" form. Though, I do not know of any other way than
Application.CreateForm(TMainForm, MainForm)
to…

Ludovic C
- 2,855
- 20
- 40
5
votes
1 answer
Delphi Spring4D IList memory overflow
I am using IList from the excellent Delphi framework Spring4D by Stefan Glienke.
I have a list IList and I refill this list many times during my application is run. So, after two or three hours I have a memory overflow of my list.
This is how I…

Aptem
- 169
- 5
5
votes
1 answer
spring4d unregister interface type (spring4d, dunitx, delphi-mocks)
I am writing one of my first unit-tests using spring4d, dunitx and delphi-mocks.
(spring4d Release 1.1 - 12.09.2014)
In my testing application, I auto-wire-inject an interface to my System under test class (sut):
IMyInterface = interface [{yes, a…

Markus
- 357
- 2
- 13
5
votes
1 answer
How to initialize main application form in Spring4D GlobalContainer?
so for instance I have a main form and want to inject a logger instance as private field.
I register the logger
GlobalContainer.RegisterType.Implements;
I have a private field in my main form
private
FLogger:…

mad
- 1,029
- 3
- 17
- 38
5
votes
1 answer
Delphi Spring framework register generic type
Using the Delphi Spring framework, is it possible to register a generic type with the GlobalContainter? I'm trying to do something like this:
TMyBaseType = class
protected
FName: string;
function GetName: string; virtual;
procedure…

Rick Wheeler
- 1,142
- 10
- 22