示例#1
0
 public static void ConnectCollection(
     ref MyObservableCollection <FilmViewModel> films,
     ref MyObservableCollection <ActorViewModel> actors,
     ref MyObservableCollection <ProducerViewModel> prods)
 {
     foreach (var actor in actors)
     {
         foreach (var film in films)
         {
             if (actor.IsInFilm(film))
             {
                 film.Actors.AddObs(actor);
             }
         }
     }
     foreach (var film in films)
     {
         foreach (var actor in film.Actors)
         {
             bool res = false;
             foreach (var act in actors)
             {
                 if (act.FullName == actor.FullName)
                 {
                     res = true;
                     break;
                 }
             }
             if (res)
             {
                 MyObservableCollection <FilmViewModel> newFilms = new MyObservableCollection <FilmViewModel>();
                 foreach (var f in actor.Films)
                 {
                     newFilms.AddObs(new FilmViewModel(f));
                 }
                 newFilms.AddObs(film);
                 actor.Films = ObsToReg(newFilms);
             }
         }
         foreach (var prod in prods)
         {
             bool res = false;
             foreach (var prodFilm in prod.Films)
             {
                 if (prodFilm.Name == film.Name)
                 {
                     res = true;
                     break;
                 }
             }
             if (res == false)
             {
                 prod.Films.Add(film.Source);
             }
         }
     }
 }