Ejemplo n.º 1
0
        PackagesToRemove(
            Array <PackageDefinition> toRemove,
            Array <PackageDefinition> packageDefinitions,
            PackageDefinition masterDefinitionFile)
        {
            var additionalToRemove = new Array <PackageDefinition>();

            foreach (var r in toRemove)
            {
                foreach (var p in packageDefinitions)
                {
                    if (p.Parents.Contains(r))
                    {
                        p.Parents.Remove(r);
                    }
                    if (0 == p.Parents.Count() && p != masterDefinitionFile && !toRemove.Contains(p))
                    {
                        additionalToRemove.AddUnique(p);
                    }
                }
            }
            if (additionalToRemove.Count() > 0)
            {
                // recurse
                additionalToRemove.AddRangeUnique(PackagesToRemove(additionalToRemove, packageDefinitions, masterDefinitionFile));
            }
            return(additionalToRemove);
        }
Ejemplo n.º 2
0
        PackagesToRemove(
            Array <PackageDefinition> toRemove,
            Array <PackageDefinition> packageDefinitions,
            PackageDefinition masterDefinitionFile)
        {
            var additionalToRemove = new Array <PackageDefinition>();

            foreach (var r in toRemove)
            {
                foreach (var p in packageDefinitions)
                {
                    if (!p.Parents.Any())
                    {
                        // immediately ignore any packages that have no parents
                        // as these are scheduled to be deleted
                        // avoids a possible infinite recursion into PackagesToRemove
                        continue;
                    }
                    if (p.Parents.Contains(r))
                    {
                        p.Parents.Remove(r);
                    }
                    if (0 == p.Parents.Count() && p != masterDefinitionFile && !toRemove.Contains(p))
                    {
                        additionalToRemove.AddUnique(p);
                    }
                }
            }
            if (additionalToRemove.Count() > 0)
            {
                // recurse
                additionalToRemove.AddRangeUnique(PackagesToRemove(additionalToRemove, packageDefinitions, masterDefinitionFile));
            }
            return(additionalToRemove);
        }