Questions tagged [spring4d]

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.

144 questions
3
votes
1 answer

Is it possible to register the same class / interface multiple times in Spring4D?

I'm currently playing around with the Spring4D framework and think it's pretty cool. I'm trying to achieve the following GlobalContainer.RegisterComponent.Implements('Normal'); …
Alister
  • 6,527
  • 4
  • 46
  • 70
3
votes
1 answer

How to use mocks with auto-wiring in Spring for Delphi?

If I have these interfaces: ISequencer = interface; IController = interface; The implementation for them (Controller requires Sequencer by contructor injection): TSequencer = class(TInterfacedObject, ISequencer) end; TController =…
Rafael Piccolo
  • 2,328
  • 1
  • 18
  • 29
3
votes
3 answers

Testing a class not declared in the interface section

I'm a newbie with Dependency Injection containers, and I am trying to get my head around using them in conjunction with Mocking. Lets say I have a controller and a list (the model): IBlahList = interface property Items[AIndex: integer]: IBlah read…
Nat
  • 5,414
  • 26
  • 38
3
votes
1 answer

How to implement a parameterized method in an interface for using in the Spring Framework

I am trying to integrate the Aurelius ORM framework and the Spring 4D framework and I am for the most part succeding, however the Aurelius ORM (and others too) rely on an "Object Manager" for the loading and saving of objects in the database. Part…
Luis Carrasco
  • 467
  • 3
  • 10
2
votes
1 answer

Spring4D should not call inherited constructor if not all parameters can be resolved

We use the dependency injection framework from Spring4D and have an issue with the way it constructs objects if it cannot resolve all constructor parameters. In our case all parameters of the constructor of the ancestor can be resolved and it looks…
Laurens
  • 325
  • 2
  • 12
2
votes
1 answer

How to test possible memory leaks caused by references after the destruction of the tested object (DUnitX, Spring4D 1.2.2)

TMyClass contains two references. A reference to an IList and a reference to IMyInterface. The mocking of IList is not necessary. The framework probably well tested, well predictable behavior, so I could see it as a Data object.…
SOLID Developper
  • 672
  • 4
  • 12
2
votes
1 answer

Delphi DSharp Mock is throwing an Unexpected Invocation error - why?

When using record types in a Delphi DUnit test with DSharp Mock for an interface, it is throwing and Unexpected Invocation but I cannot figure out why? I have created test console app below. program ConsoleStuff; {$APPTYPE CONSOLE} {$R…
Rick Wheeler
  • 1,142
  • 10
  • 22
2
votes
1 answer

Spring4D TDistinctIterator.ToArray() not working?

I want to use the Spring4D TDistinctIterator to get the distinct Values in a TDictionary. Therefore I have the following code: var d: TDictionary; v: Vector; begin d := TDictionary.Create(); d.Add(1,…
Laurens
  • 325
  • 2
  • 12
2
votes
1 answer

Spring4D TMultiMap maintain IEnumerable on the fly

I create a TMultiMap instance (Spring4D Rel 1.2.2) and immediately create an IEnumerable using the Ordered function. Then I add a few items to the multimap. When using the IEnumerable created when the multimap was empty, I list all the items and…
fpiette
  • 11,983
  • 1
  • 24
  • 46
2
votes
1 answer

Can't use default parametr values with comparer in Spring4D

I'm not sure if this is some generic problem or it's because of Spring4D implementation, but I can't use default parameter values for creating comparer. type TMyClass = class class function MyComparer(AParam: Boolean = False):…
Triber
  • 1,525
  • 2
  • 21
  • 38
2
votes
1 answer

Spring4d - Automatic factory with service name

I am trying to use the automatic virtual factory functionality of Spring4d. Though, I would like to be able to pass the ServiceName I want to resolve inside the factory Build() function. Like so : AFactory.Build(AServiceName) For…
Ludovic C
  • 2,855
  • 20
  • 40
2
votes
0 answers

Containers behind interface how can i spy content in debug

I'm using Spring4d where are interfaced containers like IList. If I use normal version of container I can spy its content in debug by move mouse over variable. But if variable is interface I see somethink like this: TClassName($1234567) as…
aQuu
  • 565
  • 8
  • 18
2
votes
2 answers

How to collapse an IEnumerable of an IEnumerable to a single IEnumerable?

function TSomething.Concat(const E: IEnumerable>): IEnumerable; begin Result := TConcatIterator.Create(E) as IEnumerable; end; That doesn't compile, because TConcatIterator can only concat two enumerables, but what I…
Jens Mühlenhoff
  • 14,565
  • 6
  • 56
  • 113
2
votes
2 answers

TForm management in Spring4D

I have the following code: Project.dpr program Project2; uses madExcept, madLinkDisAsm, madListHardware, madListProcesses, madListModules, Spring.Container, Vcl.Forms, uRegistrations in '..\Memory leak II\uRegistrations.pas', …
pio pio
  • 732
  • 1
  • 7
  • 29
2
votes
1 answer

How use multi interface class in Spring4D

I'm just learning Spring4D and i have one question. If class implement only one interface its all clear: IWeapon = interface ['{E679EDA6-5D43-44AD-8F96-3B5BD43A147B}'] procedure Attack; end; TSword =…
aQuu
  • 565
  • 8
  • 18