The documentation states that Autofac supports open generics and I am able to register and resolve in a basic case like so:
Registration:
builder.RegisterGeneric(typeof(PassThroughFlattener<>))
.As(typeof(IFlattener<>))
.ContainerScoped();
Resolve:
var flattener = _container.Resolve<IFlattener<Address>>();
The above code works just fine. However, assuming that I will not know the type provided to IFlattener until runtime, I want to do something like this:
object input = new Address();
var flattener = (IFlattener)_container.Resolve(typeof(IFlattener<>), new TypedParameter(typeof(IFlattener<>), input.GetType()));
Is this possible with AutoFac? I got the idea from the following using StructureMap:
http://structuremap.sourceforge.net/Generics.htm
I'm trying to achieve the same goal outlined in this article.