I have a question about delegate factories: autofac docs
I understand how they set up the factories but I do not get the resolving part:
var shareholdingFactory = container.Resolve<Shareholding.Factory>();
var shareholding = shareholdingFactory.Invoke("ABC", 1234);
It looks like you have to pass around the container in order to resolve. Maybe I have to Invoke something with parameters I only know at runtime. How do I do that without passing the container to for example a service method?
UPDATE
So you are supposed to pass the factories instead?
Autofac can automatically resolve factories, i.e. without the container:
Autofac registration
Now, if your ShareHolding type had ctor like:
Then you would need a delegate factory because Autofac resolves constructors using type information and delegate factories using parameters names. Your usage would then become: