private int changeParticipants(Team newTeam) { int num = 0; foreach (Category category in this.categories) { category.getParticipants().RemoveAll((Predicate <Participant>)(p => p.getTeam() == newTeam.getName())); } using (List <Participant> .Enumerator enumerator = newTeam.getParticipants().GetEnumerator()) { while (enumerator.MoveNext()) { Participant p = enumerator.Current; foreach (Category category in this.categories) { try { category.getParticipants().First <Participant>((Func <Participant, bool>)(s => s.getId() == p.getId())).setName(p.getName()); if (!category.getParticipants().Contains(p) && category.getFilter().participantMatch(p)) { category.getParticipants().Add(p); ++num; } } catch (Exception ex) { if (!category.getParticipants().Contains(p) && category.getFilter().participantMatch(p)) { p.setTeam(newTeam.getName()); category.getParticipants().Add(p); } ++num; } } } } return(num); }
public bool Equals(Participant p) { return(p.getId() == this.getId()); }