zcz527 / autofac

Automatically exported from code.google.com/p/autofac
Other
0 stars 0 forks source link

Func<IMyInterface> returns the old type if the impl of the interfaces was updated #340

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Version: 2.5.2.830

Original issue reported on code.google.com by lanwin...@gmail.com on 16 Aug 2011 at 2:24

GoogleCodeExporter commented 8 years ago
Thanks for the report. It may be a little surprising, but this is a by-design 
consequence of the way adapters are implemented in Autofac.

Each Func<T> component is permanently bound to its underlying T component, so 
to get an updated Func<T> when the default T changes, Func<T> would need to be 
re-resolved (to get a new default Func<T>.)

This arises because of the possibility of there being multiple implementations 
of T. If, say, IEnumerable<Func<T>> returned three distinct results, adding a 
new fourth implementation should not change the semantics of the existing three.

Hope this makes sense. If you're stuck and really need this to work without 
referencing IComponentContext to re-resolve Func<T>, then Func<Func<T>> might 
help.

Cheers,
Nick

Original comment by nicholas...@gmail.com on 16 Aug 2011 at 8:33