I've defined a class which takes a repository instance as the sole constructor argument. And now that I created a static instance of that class, MainViewModel
the constructor arguments need to be specified.
Issue:
In order to specify the required arguments, I added the IRepository argument as expected in the static instance of the MainVM class.
This didn't work as expected as the compiler is throwing the following errors as a result of this:
Using the generic type 'ParkingTagPicker.DAL.IRepository<T>' requires 1 type arguments
ParkingTagPicker.Models.Zone' is a 'type' but is used like a 'variable'
The name 'zoneDataService' does not exist in the current context
From looking at the errors it seems the IRepository is being supplied with the correct Zone
type.
Does anyone know how to correctly define the constructor args in this situation?
MainViewModel:
//IRepository instance with Zone type arg
//(Zone is a model class)
private IRepository<Zone> _zoneDataService;
public MainViewModel(IRepository<Zone> zoneDataService)
{
this._zoneDataService = zoneDataService;
}
App.xaml.cs:
/// <summary>
/// A static ViewModel used by the views to bind against.
/// </summary>
/// <returns>The MainViewModel object.</returns>
public static MainViewModel ViewModel
{
get
{
// Delay creation of the view model until necessary
if (viewModel == null)
viewModel = new MainViewModel(IRepository<Zone> zoneDataService);
return viewModel;
}
}