IEnumerable<PersonViewModel> FindMatches(string searchText, PersonViewModel person) { if (person.NameContainsText(searchText)) yield return person; foreach (PersonViewModel child in person.Children) foreach (PersonViewModel match in this.FindMatches(searchText, child)) yield return match; }
private PersonViewModel(Person person, PersonViewModel parent) { _person = person; _parent = parent; _children = new ReadOnlyCollection<PersonViewModel>( (from child in _person.Children select new PersonViewModel(child, this)) .ToList<PersonViewModel>()); }
public FamilyTreeViewModel(Person rootPerson) { _rootPerson = new PersonViewModel(rootPerson); _firstGeneration = new ReadOnlyCollection<PersonViewModel>( new PersonViewModel[] { _rootPerson }); _searchCommand = new SearchFamilyTreeCommand(this); }