Inject Dependencies into Command Settings #1147
-
I have a I was planning on injecting an Is this kind of scenario of injecting dependencies into a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This was resolved with a pretty simple fix. I had forgotten that the actual settings class also needs to be registered: public static class TypeRegistrarConfigurator
{
public static ITypeRegistrar ConfigureTypeRegistrar()
{
var serviceCollection = new ServiceCollection();
serviceCollection.AddSingleton<IFileSystem, FileSystem>();
serviceCollection.AddSingleton<IFile, FileWrapper>();
serviceCollection.AddTransient<ConvertSettings>(); // adding this fixed things
return new TypeRegistrar(serviceCollection);
}
} Leaving this up in case it helps anyone else. 😄 |
Beta Was this translation helpful? Give feedback.
This was resolved with a pretty simple fix. I had forgotten that the actual settings class also needs to be registered:
Leaving this up in case it helps anyone else. 😄