@Steven is right, it is not possible to resolve generic types without knowing what types they embed. However there are two ways to sidestep the problem
Either you have a closed list of possible input and outputs types, on which you can iterate in order to resolve all specific combinations
for var Type1 in PossibleTypes1
for var Type2 in PossibleTypes2
var list = container.ResolveAll(typeof(IQuery<,>).MakeGenericType(Type1, Type2)
This is not really elegant but you can get all your queries. However I'd like to propose the second alternative.
If you want to resolve all your queries, you must have an operation you want to call on them, or some information you would like to get out. If so then this operation or information should exist inside a base non-generic interface that your generic interface inherits from. Let's say you want to get the operation name, you could do something like:
public interface IBaseQuery {
string getOperationName(); // your common operation
}
public interface IQuery<In, Out>: IBaseQuery {
}
You would then register your IQuery
implementations against all their interfaces and resolve IBaseQuery
to call the common implementation for all your queries.
container.ResolveAll(typeof(IQuery<int, double>))
. – Steven