I am developing a new MVVM light Wpf application.I have 25 View and ViewModels and 25 DataService Interface and its implementations (One implementation for Design time Data service and one for realtime dataservice).
For Eg, Here is a my DataService Interface for my SupplierViewModel:
interface ISupplierDataService
{
ObservableCollection<Tbl_Supplier> GetAllSuppliers();
int GetSupplierCount(string supplierNameMatch);
}
and Here is its implementation for design time :
class SupplierDataServiceMock : ISupplierDataService
{
public ObservableCollection<Tbl_Supplier> GetAllSuppliers()
{
.....
}
public int GetSupplierCount(string supplierNameMatch)
{
....
}
}
class SupplierDataService : ISupplierDataService
{
public ObservableCollection<Tbl_Supplier> GetAllSuppliers()
{
....
}
public int GetSupplierCount(string supplierNameMatch)
{
....
}
}
In ViewModelLocator is I need to register all my 25 ViewModels and its 25 DataService and its implementations like this :
static ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
if (ViewModelBase.IsInDesignModeStatic)
{
SimpleIoc.Default.Register<ISupplierDataService, SupplierDataServiceMock>();
SimpleIoc.Default.Register<ICustomerDataService, CustomerDataServiceMock>();
....
}
else
{
SimpleIoc.Default.Register<ISupplierDataService, SupplierDataService>();
SimpleIoc.Default.Register<ICustomerDataService, CustomerDataService>();
....
}
SimpleIoc.Default.Register<MainViewModel>();
SimpleIoc.Default.Register<SupplierViewModel>();
SimpleIoc.Default.Register<CustomerViewModel>();
....
}
My question is do I need to register all my 25 ViewModels and its 25 DataService in my ViewModelLocator ?