delphispring4d

In Spring4D is it not possible to register a TPair<String,String>?


The following code gives the error 'Incomplete registration for type: TPair<System.string,System.string>' but for the life of me I can't figure out what is missing.
I even tried registering String.

var Container:=TContainer.Create;
try
  Container.RegisterType<TPair<String,String>>().InjectConstructor(['A','B']);
  Container.Build;
  var A:=Container.Resolve<TPair<String,String>>;
  OutputDebugString(PChar(A.Key));
finally
  Container.Free;
end;

Solution

  • Simply do:

    Container.RegisterInstance(TPair<string,string>.Create('A', 'B'));
    

    That will let the container know about TPair<string,string> which has those given Key and Value.