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
3
votes
1 answer
Simple example how to Invoke TEvent with params
I'm trying to use the Spring4d framework for Delphi and I want to use the Multicast Events. While using the "normal" TNotifyEvent, it works and the handler will get called twice.
uses
...
Spring,
Spring.Events,
Spring.Events.Base;
procedure…

ReneS
- 33
- 3
3
votes
1 answer
Delphi Spring Mock of reference to function
I have an interface and I want to mock a function of this interface with an argument which is a reference to a function. See code exmple:
unit Main;
interface
procedure Execute;
implementation
uses
Spring.Mocking;
type
TRefFunc = reference…

FlorianSchunke
- 571
- 5
- 15
3
votes
1 answer
What is the correct way to copy the dictionary?
I need to check if there has been a change in a certain part of the application and therefore I make "copies" of the data after loading them and then compare them. One part of the comparison function involves checking keys in dictionaries like…

Triber
- 1,525
- 2
- 21
- 38
3
votes
1 answer
Is there a Spring4D correspondent function to WillReturnDefault
Delphi-Mocks has a WillReturnDefault method when you don't care about the parameters of a function. I can't figure out how to do that with Spring4D mocking. Grateful for help!

Anders Gustavsson
- 65
- 5
3
votes
0 answers
Spring4d and TWebBroker
(The same question exists in Spring4d google group)
I have a big doubt (it's more than a doubt, I have some thread related troubles...): I am developing a web app with Delphi WebBroker technology; where do I put my registrations with the Spring4D…

Eddy M.
- 31
- 1
- 3
3
votes
2 answers
How to create and use a case insensitive IList in Spring4d
I'm trying the following code to create a case insensitive IList:
procedure TForm1.ListButtonClick(Sender: TObject);
var
MyList: IList;
begin
MyList := TCollections.CreateList(TStringComparer.OrdinalIgnoreCase());
…

MarkF
- 1,616
- 1
- 17
- 27
3
votes
1 answer
How to implement a Enumerator that has IsFirst and IsLast functions?
I am using Spring4D for all collections.
Now there is a situation where I have to know whether the current value of the enumerator is the first (which is easy) or the last (which is hard) in the collection.
program Project1;
{$APPTYPE CONSOLE}
{$R…

Jens Mühlenhoff
- 14,565
- 6
- 56
- 113
3
votes
1 answer
"Unsatisfied constructor" on constructor injection with Spring4D
I'm struggling with the constructor injection of Spring4D. In a certain class i want to inject a specific implementation (by name) of an interface into the constructor.
Look at this:
IListFactory = interface
['{40...29}']
function GetList :…

Mik
- 35
- 5
3
votes
2 answers
Spring4d : Automatic factory with Owner : TComponent parameter?
With Spring4d, you can register custom factories like so
aContainer.RegisterInstance>(function(aName : string):TMyObject
begin
Result := TMyObject.Create(aName);
end);
In this manner, I would beleive that for every…

Ludovic C
- 2,855
- 20
- 40
3
votes
1 answer
How to inject field interface into an object
I want to inject an interface into an object but I can't find the problem of the attribute [Inject]
What's working.
unit uStorage;
interface
uses
uStorageInterface;
type
TStorageService = class (TInterfacedObject, IStorageService)
private
…

Ravaut123
- 2,764
- 31
- 46
3
votes
3 answers
How can I pass a string value as a parameter when calling GlobalContainer.Resolve in Spring4D?
When using Spring4D, how can I pass a string value as a parameter when calling GlobalContainer. Resolve so that this string value is used on the resolved class constructor?
I want to resolve a class IWorker that is mapped to a TWorker. The TWorker…

Setzer0384
- 43
- 1
- 7
3
votes
1 answer
Are there any methods built into the Spring framework that make working with polymorphic containers easier?
I have a dictionary that contains different kinds of values and I want to filter for an item that has a specific sub-type and that satisfies a certain condition:
var
FData: IDictionary; // Polymorphic
begin
…

Jens Mühlenhoff
- 14,565
- 6
- 56
- 113
3
votes
3 answers
Cannot get expected result for Spring4D cryptography examples
The Spring4D library has cryptography classes, however I cannot get them to work as expected. I'm probably using them incorrectly, however lack of any examples makes it difficult.
For example on the website https://quickhash.com/hash-sha256-online,…

Rick Wheeler
- 1,142
- 10
- 22
3
votes
1 answer
How do I use THasAttributeFilter in Spring4d
I would like to query some attributes (aka annotations) in a class I'm writing.
I can do it the complex way, but I'd like to use Spring4D instead.
It has a unit called Reflection that looks like it has what I need, but I don't know how to use it. …

Johan
- 74,508
- 24
- 191
- 319
3
votes
2 answers
Delphi mocking with nullable types
What is the best way to setup Delphi DSharp mocks with Nullable types from the Spring framework? I've tried various approaches and I know I'm probably missing something really rudimentary, but I just can't figure out how to get the following code to…

Rick Wheeler
- 1,142
- 10
- 22