Spring4D and factory

Spring4D and factory

A very simple example:

IExample = interface ['{0F1BE36B-0735-4BCE-BAF7-AC0AC3B60A16}']
end;

TExample = class(TInterfacedObject, IExample)
public
constructor Create(const aId: UInt32; const aObject: TObject);
end;

{$M+}
TExampleFactory = reference to function(const aId: UInt32; const aObject: TObject) : IExample;
{$M-}

aContainer.RegisterType.Implements;
aContainer.RegisterFactory;


When I call the factory:

lExample := aExampleFactory(2, nil); <- exception

I get an exception:

"Unsatisfied constructor on type TExample"

When I call other, not nil value then is ok. Is it not allowed to transfer nil to factories?

Comments

  1. imho breaking changes is acceptable if current architecture blocks development. Maybe it's worth doing a survey? I think that many interested will agree. Especially if the changes are clearly described.

    ReplyDelete
  2. Jacek Laskowski There will be breaking changes but I said "unintentionally" and that is what has to be avoided.

    ReplyDelete
  3. Stefan Glienke Ok, thanks for your effort

    ReplyDelete

Post a Comment