I have a class which takes a Func
as a constructor argument:
public CurrencyCache(Func<IEnumerable<Currency>> loadData)
The Func
is basically the method to call when the cache has expired
When I register this in AutoFac I need to specify the method. And to do that I need to resolve a dependency from the container. Except I can’t as the container isn’t built yet
builder.Register(o => new CurrencyCache(<some code to resolve the class with the method I want to call>));
I don’t want to manually new-up the dependency graph to this class as it is a few levels deep and needs various data from config files etc
So I want the container to resolve the class for me
But as I say, the container isn’t built yet
Is there a way around this? Does Autofac have some api to deal with such a scenario