MVVM IoC Registration across Projects #4154
Unanswered
Pinox
asked this question in
Questions & Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Guys, @Sergio0694 , @michael-hawker
In MvvmLight I can easily register a class in any of my projects, therefor I do not have a specific entry point to register a class.
SimpleIoc.Default.Register();
In the Toolkit.Mvvm I have a specific entry point.
Ioc.Default.ConfigureServices(
new ServiceCollection()
.AddSingleton()
.BuildServiceProvider());
Question 1
How can I reuse the existing ServerCollection in a different project and add more items (for registration) to it without resorting to constructor injection etc.
I'm looking for something like :
Ioc.Default.ExistingService(
.AddSingleton()
.ReBuildServiceProvider());
I ended up changing my code base to instantiate Ioc.Default.ConfigureServices() from the root app so I got everything working again, but this was a nice feature of MvvmLight where you can add more services from any project.
Question 2
With most templates in .NET starting to embrace the default asp.net core HostBuilder.
Is there plans to integrate toolkit.mvvm with the generic hostbuilder ?
example:
var host = new HostBuilder()
.ConfigureServices((c, x) =>
//Add this line to call back into your native code
AddToolkitMvvm(c, x);
})
.Build();
Where we can add the toolkit.mvvm to the generic host builder but still access the instances through the convenient
Ioc.Default.GetServices that is cross project instead of the default hostbuilder ServiceProvider.GetService();
Beta Was this translation helpful? Give feedback.
All reactions