Autofac register and resolve types implementing a generic interace?

There is no way this is going to work Here is the reason why: An IHandler.

There is no way this is going to work. Here is the reason why: An IHandler requires an IConfiguration as parameter to Handle. If your first line would be valid, the following would compile: MyOtherConfiguration config = new MyOtherConfiguration(); IHandler test = new MyHandler(); test.

Handle(config); Obviously, this is not correct, because MyHandler. Handle wants a MyConfiguration or derived type. Using contra-variance as described in my earlier version of this answer would allow you to do the following: IHandler test = new MyHandler(); with MyDerivedConfiguration being derived from MyConfiguration.

Tried that, and it still doesn't work. Tried out T aswell, then the assignment works, but not the implementation of the handler won't compile. – MatteS Aug 8 at 11:59 @MatteS: You are right.

Please see updated answer. – Daniel lgarth Aug 8 at 12:09 Thanks alot, now its completely clear to me why this doesn't work. I think ill have to rethink my design.

Or if not that, maybe its feasable to call my handler using reflection. – MatteS Aug 8 at 13:32 After some googling I see a similar de – Daniel lgarth Aug 8 at 14:05.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions