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

93 Views Asked by At

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;
1

There are 1 best solutions below

2
Stefan Glienke On BEST ANSWER

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.