vdhant - You're doing it wrong.
You want to use ISubject
, right?. Then if you passed T you're breaking your abstraction, because your caller must know that ISubject
, is actually a Subject, and more than that, its a Subject<T>
and that it requires a concrete T.
No container will allow that, but it's a design problem, not tool problem.
One thing to fix your design, would be to make it explicit - change ISubject
to ISubject<T>
Then you could register open generic type ISubject<>
and bind it to open generic type Subject<>
.
container.AddComponent(typeof(ISubject<>),typeof(Subject<>));
Then you'd be able to do
var fooSubject = container.Resolve<ISubject<Foo>>();
You didn't provide any context so I may be off the track with the answer, but one thing is for sure - you have a design problem.