Class AppInstaller
- Namespace
- EasySoftware.MvvmMini
- Assembly
- EasySoftware.MvvmMini.dll
Extension methods that register MvvmMini with IServiceCollection and create view models with their views.
public static class AppInstaller
- Inheritance
-
AppInstaller
- Inherited Members
Methods
AddMvvmMini(IServiceCollection, Action<IViewModelViewMapping>)
Registers the MvvmMini services: the view model to view mapping and a singleton IEventAggregator.
public static IServiceCollection AddMvvmMini(this IServiceCollection services, Action<IViewModelViewMapping> mappingRegistrator)
Parameters
servicesIServiceCollectionThe service collection to add the services to.
mappingRegistratorAction<IViewModelViewMapping>An action that registers each view model interface with its view model and view.
Returns
- IServiceCollection
The same service collection, so calls can be chained.
Examples
services.AddMvvmMini(mapper =>
{
mapper.RegisterViewModelWithView<IShellViewModel, ShellViewModel, ShellView>();
});
GetViewModel(IServiceProvider, Type, params object[])
Creates the view model registered for the given view model interface together with its view.
public static IViewModel GetViewModel(this IServiceProvider serviceProvider, Type viewModelInterfaceType, params object[] openArgs)
Parameters
serviceProviderIServiceProviderThe service provider used to resolve the constructor dependencies of the view and the view model.
viewModelInterfaceTypeTypeThe view model interface that was registered with RegisterViewModelWithView<TIViewModel, TViewModel, TView>().
openArgsobject[]Extra constructor arguments for the view model that are not resolved from the service provider.
Returns
- IViewModel
A new view model instance whose view is already created and bound to it.
Exceptions
- Exception
The view model interface is not registered.
GetViewModel<TIViewModel>(IServiceProvider, params object[])
Creates the view model registered for TIViewModel together with its view.
public static TIViewModel GetViewModel<TIViewModel>(this IServiceProvider serviceProvider, params object[] openArgs)
Parameters
serviceProviderIServiceProviderThe service provider used to resolve the constructor dependencies of the view and the view model.
openArgsobject[]Extra constructor arguments for the view model that are not resolved from the service provider.
Returns
- TIViewModel
A new view model instance whose view is already created and bound to it.
Type Parameters
TIViewModelThe view model interface that was registered with RegisterViewModelWithView<TIViewModel, TViewModel, TView>().
Exceptions
- Exception
The view model interface is not registered.