I am using a LoggerService
in my ViewModelBase
, which is injected in constructor:
public abstract class ViewModelBase : INotifyPropertyChanged
{
private ILoggerService _loggerService;
public ViewModelBase(ILoggerService loggerService)
{
_loggerService = loggerService;
}
...
...
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
But in my ViewModelOne
, which inherits from ViewModelBase
, I need to use this service, what should I do?
- To do public the
_loggerService
inViewModelBase
and use it fromViewModelOne
. - To inject again the interface in the constructor of
ViewModelOne
.
In your opinion, which would be the best approach? Or...what would you do?
Aucun commentaire:
Enregistrer un commentaire