Spring resolver problem...
Spring resolver problem...
I try resolve factory method (previously registered in container) and I get compile error:
{$M+}
TCompaniesManagerFactory = reference to function(const aAuthKey : RAuthKey) : ICompaniesManager;
{$M-}
var
lCompaniesManagerFactory : TCompaniesManagerFactory;
begin
lCompaniesManagerFactory := Container.Resolve; <- line with error
Error:
[dcc32 Error] E2010 Incompatible types: 'TCompaniesManagerFactory' and 'Procedure of object'
ps. I know about composition root and others IoC rules... please tell me why I get compile error, types are compatible
I try resolve factory method (previously registered in container) and I get compile error:
{$M+}
TCompaniesManagerFactory = reference to function(const aAuthKey : RAuthKey) : ICompaniesManager;
{$M-}
var
lCompaniesManagerFactory : TCompaniesManagerFactory;
begin
lCompaniesManagerFactory := Container.Resolve
Error:
[dcc32 Error] E2010 Incompatible types: 'TCompaniesManagerFactory' and 'Procedure of object'
ps. I know about composition root and others IoC rules... please tell me why I get compile error, types are compatible
Sorry, I use Spring4D of course.
ReplyDeleteHow to fix this problem?
Put parentheses on your call. When assigning a function call result to an anonymous method variable it does not consider calling the method to get an assignment compatible result. Most simple case:
ReplyDeleteuses
System.SysUtils;
function GiveProc: TProc;
begin
end;
var
p: TProc;
begin
p := GiveProc; // <- E2010 - write GiveProc() and it works
end.
Stefan Glienke Thx! Mea culpa, stupid (and hidden) error :-)
ReplyDelete