In Autofac it possible to make TypedParameter lazy? Moreover, I need access to the container when entering the parameter. The code might look like this:
builder.RegisterType<RootService>() .WithParameter(TypedParameter.From(c => c.Resolve<IChildService>(key)));
Update
Based on Nick's answer, I created the following helper method:
public static class TypedResolvedParameter { public static ResolvedParameter From<T>(Func<IComponentContext, T> factory) { return new ResolvedParameter( (pi, c) => pi.ParameterType == typeof(T), (pi, c) => factory(c)); } }
autofac
Konstantin spirin
source share