Ejemplo n.º 1
0
        private void AddDependencies(Product p, Hashtable availableProducts)
        {
            foreach (string relatedProductCode in SelectRelatedProducts(p, "DependsOnProduct"))
            {
                if (availableProducts.Contains(relatedProductCode))
                {
                    p.AddDependentProduct((Product)availableProducts[relatedProductCode]);
                }
                else
                {
                    ArrayList missingDependencies = new ArrayList();
                    missingDependencies.Add(relatedProductCode);
                    p.AddMissingDependency(missingDependencies);
                }
            }

            foreach (XmlNode eitherProductNode in SelectEitherProducts(p))
            {
                List<Product> foundDependencies = new List<Product>();
                ArrayList allDependencies = new ArrayList();

                foreach (XmlNode relatedProductNode in eitherProductNode.SelectNodes(String.Format(CultureInfo.InvariantCulture, "{0}:DependsOnProduct", BOOTSTRAPPER_PREFIX), _xmlNamespaceManager))
                {
                    XmlAttribute relatedProductAttribute = (XmlAttribute)(relatedProductNode.Attributes.GetNamedItem("Code"));
                    if (relatedProductAttribute != null)
                    {
                        string dependency = relatedProductAttribute.Value;
                        if (availableProducts.Contains(dependency))
                        {
                            foundDependencies.Add((Product)availableProducts[dependency]);
                        }
                        allDependencies.Add(dependency);
                    }
                }

                if (foundDependencies.Count > 0)
                {
                    if (!p.ContainsDependencies(foundDependencies))
                    {
                        p.Dependencies.Add(foundDependencies);
                    }
                }
                else if (allDependencies.Count > 0)
                {
                    p.AddMissingDependency(allDependencies);
                }
            }
        }
 private void AddDependencies(Product p, Hashtable availableProducts)
 {
     foreach (string str in this.SelectRelatedProducts(p, "DependsOnProduct"))
     {
         if (availableProducts.Contains(str))
         {
             p.AddDependentProduct((Product) availableProducts[str]);
         }
         else
         {
             ArrayList productCodes = new ArrayList();
             productCodes.Add(str);
             p.AddMissingDependency(productCodes);
         }
     }
     foreach (XmlNode node in this.SelectEitherProducts(p))
     {
         List<Product> dependenciesToCheck = new List<Product>();
         ArrayList list3 = new ArrayList();
         foreach (XmlNode node2 in node.SelectNodes(string.Format(CultureInfo.InvariantCulture, "{0}:DependsOnProduct", new object[] { "bootstrapper" }), this.xmlNamespaceManager))
         {
             XmlAttribute namedItem = (XmlAttribute) node2.Attributes.GetNamedItem("Code");
             if (namedItem != null)
             {
                 string key = namedItem.Value;
                 if (availableProducts.Contains(key))
                 {
                     dependenciesToCheck.Add((Product) availableProducts[key]);
                 }
                 list3.Add(key);
             }
         }
         if (dependenciesToCheck.Count > 0)
         {
             if (!p.ContainsDependencies(dependenciesToCheck))
             {
                 p.Dependencies.Add(dependenciesToCheck);
             }
         }
         else if (list3.Count > 0)
         {
             p.AddMissingDependency(list3);
         }
     }
 }