I have a Translation class that takes in ITranslationService
as its argument. How do I inject translation service when registering the Lazy<Translation>
type? This is what I've done so far, but no luck.
public class Translation
{
public Translation(ITranslationService translationService)
{
// code here
}
}
container.RegisterType<ITranslationService, TranslationService>();
container.RegisterType<Lazy<Translation>>(new InjectionConstructor(typeof(ITranslationService)));
Error message when trying to resolve Lazy<Translation>
type:
The lazily-initialized type does not have a public, parameterless constructor
ImportingConstructor
as an attribute? – Default