private void followAsmasAndRemoveUnused(IMa rootMa)
 {
     foreach (IAsma asma in rootMa.Asmas)
     {
         if (asma.AssociatedBieAggregator.IsMa)
         {
             followAsmasAndRemoveUnused(asma.AssociatedBieAggregator.Ma);
         }
         if (asma.AssociatedBieAggregator.IsAbie)
         {
             List <CheckableTreeViewItem> result =
                 findCheckableTreeViewItems(asma.AssociatedBieAggregator.Abie.Name,
                                            mCandidateAbieItems);
             if (result == null)
             {
                 rootMa.RemoveAsma(asma);
             }
             else
             {
                 if (testIfAllCheckableTreeViewItemsAreUnchecked(result))
                 {
                     rootMa.RemoveAsma(asma);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        private static bool PruneMa(IMa ma)
        {
            if (!alreadyPrunedItems.Contains(ma.Id))
            {
                alreadyPrunedItems.Add(ma.Id);

                List <IAsma> asmas = new List <IAsma>(ma.Asmas);

                foreach (IAsma asma in asmas)
                {
                    if (asma.AssociatedBieAggregator.IsMa)
                    {
                        IMa associatedMa = asma.AssociatedBieAggregator.Ma;

                        if (PruneMa(associatedMa))
                        {
                            masToBeRemoved.Add(associatedMa.Id);
                            ma.RemoveAsma(asma);
                        }
                    }
                    else if (asma.AssociatedBieAggregator.IsAbie)
                    {
                        IAbie abie = asma.AssociatedBieAggregator.Abie;

                        if (PruneAbie(abie))
                        {
                            abiesToBeRemoved.Add(abie.Id);
                            ma.RemoveAsma(asma);
                        }
                    }
                }

                if (ma.Asmas.Count() == 0)
                {
                    return(true);
                }

                return(false);
            }
            return(masToBeRemoved.Contains(ma.Id));
        }