My goal is to find any of my viewmodels that are dirty and when they exit the app , I should let them notify.
I can get to an instance based on type by below code but problem is its going to create instances for all view models as I am only interested in the ones which were already created by MEF container
List<Type> viewModelInterfaces = new List<Type>();
I can get to an instance based on type by below code but problem is its going to create instances for all view models as I am only interested in the ones which were already created by MEF container
List<Type> viewModelInterfaces = new List<Type>();
viewModelInterfaces .Add(typeof(IAddressViewModel));
viewModelInterfaces .Add(typeof(ICustomerNameViewModel));
viewModelInterfaces .Add(typeof(IBudgetSummaryViewModel));
foreach (var appInterface in viewModelInterfaces )
{
var obj = Container.GetExports(appInterface, ull,appInterface.FullName).FirstOrDefault();
if (obj != null)
{
var viewModel = obj.Value as IViewModelBase;
if (viewModel != null)
{
if (viewModel.IsDirty)
{
Show Dialog
}
}
}
}