А что если нужно реализовать поиск и вывод в консольном или ASP.NET Core приложении? Каким боком там INotifyPropertyChanged? Это неправильно
abstract class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = "")
{
if (EqualityComparer<T>.Default.Equals(storage, value))
return false;
storage = value;
OnPropertyChanged(propertyName);
return true;
}
}
class SearchInfo : ViewModelBase
{
string _currentDirectory;
int _foundCounter;
int _checkedCounter;
bool _finished;
public bool Finished
{
get { return _finished; }
set { SetProperty(ref _finished, value); }
}
public string CurrentDirectory
{
get { return _currentDirectory; }
set { SetProperty(ref _currentDirectory, value); }
}
public int FoundCounter
{
get { return _foundCounter; }
set { SetProperty(ref _foundCounter, value); }
}
public int CheckedCounter
{
get { return _checkedCounter; }
set { SetProperty(ref _checkedCounter, value); }
}
}
Info = new SearchInfo();
_search = new Search(Settings.Default.DefaultDirectory, Settings.Default.FileNameRegex, FoundItems, Info);