Exemple #1
0
 public Package(Product product, XmlNode node, XmlValidationResults validationResults, string name, string culture)
 {
     _product = product;
     _node = node;
     _name = name;
     _culture = culture;
     _validationResults = validationResults;
 }
 internal void AddDependentProduct(Product product)
 {
     List<Product> list;
     list = new List<Product> {
         product,
         list
     };
 }
 internal void Add(Product product)
 {
     if (!_table.Contains(product.ProductCode.ToUpperInvariant()))
     {
         _list.Add(product);
         _table.Add(product.ProductCode.ToUpperInvariant(), product);
     }
     else
     {
         System.Diagnostics.Debug.WriteLine("Product '{0}' has already been added to the product list", product.ProductCode.ToUpperInvariant());
     }
 }
        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 AddIncludedProducts(Product product, Dictionary<string, Product> includedProducts)
 {
     if (!includedProducts.ContainsKey(product.ProductCode))
     {
         includedProducts.Add(product.ProductCode, product);
         foreach (Product p in product.Includes)
         {
             AddIncludedProducts(p, includedProducts);
         }
     }
 }
 private void AddProduct(Dictionary<string, Product> output, Product product)
 {
     if (!output.ContainsKey(product.ProductCode.ToLowerInvariant()))
         output.Add(product.ProductCode.ToLowerInvariant(), product);
 }
        private Package CreatePackage(XmlNode node, Product product)
        {
            string culture = ReadAttribute(node, "Culture");

            XmlValidationResults results = null;
            if (culture != null)
            {
                results = product.GetPackageValidationResults(culture);
            }
            else
            {
                return null;
            }

            return new Package(product, node, results, ReadAttribute(node, "Name"), ReadAttribute(node, "Culture"));
        }
        private Dictionary<string, Product> GetIncludedProducts(Product product)
        {
            Dictionary<string, Product> includedProducts = new Dictionary<string, Product>(StringComparer.OrdinalIgnoreCase);

            // Add in this product in case there is a circular includes: 
            // we won't continue to explore this product.  It will be removed later.
            includedProducts.Add(product.ProductCode, product);

            // Recursively add included products 
            foreach (Product p in product.Includes)
            {
                AddIncludedProducts(p, includedProducts);
            }

            includedProducts.Remove(product.ProductCode);
            return includedProducts;
        }
 private XmlNodeList SelectEitherProducts(Product p)
 {
     return p.Node.SelectNodes(string.Format(CultureInfo.InvariantCulture, "{0}:Package/{1}:RelatedProducts/{2}:EitherProducts", new object[] { "bootstrapper", "bootstrapper", "bootstrapper" }), this.xmlNamespaceManager);
 }
        private Product CreateProduct(XmlNode node)
        {
            bool fPackageAdded = false;
            string productCode = ReadAttribute(node, "ProductCode");
            Product product = null;
            if (!String.IsNullOrEmpty(productCode))
            {
                ProductValidationResults results = (ProductValidationResults)_validationResults[productCode];

                XmlNode packageFilesNode = node.SelectSingleNode(BOOTSTRAPPER_PREFIX + ":Package/" + BOOTSTRAPPER_PREFIX + ":PackageFiles", _xmlNamespaceManager);
                string copyAllPackageFiles = String.Empty;

                if (packageFilesNode != null) copyAllPackageFiles = ReadAttribute(packageFilesNode, "CopyAllPackageFiles");

                product = new Product(node, productCode, results, copyAllPackageFiles);
                XmlNodeList packageNodeList = node.SelectNodes(BOOTSTRAPPER_PREFIX + ":Package", _xmlNamespaceManager);

                foreach (XmlNode packageNode in packageNodeList)
                {
                    Package package = CreatePackage(packageNode, product);
                    if (package != null)
                    {
                        product.AddPackage(package);
                        fPackageAdded = true;
                    }
                }
            }

            if (fPackageAdded)
                return product;
            return null;
        }
 private XmlNodeList SelectEitherProducts(Product p)
 {
     XmlNodeList eitherProducts = p.Node.SelectNodes(string.Format(CultureInfo.InvariantCulture, "{0}:Package/{1}:RelatedProducts/{2}:EitherProducts", BOOTSTRAPPER_PREFIX, BOOTSTRAPPER_PREFIX, BOOTSTRAPPER_PREFIX), _xmlNamespaceManager);
     return eitherProducts;
 }
Exemple #12
0
 internal void AddIncludedProduct(Product product)
 {
     _includes.Add(product);
 }
 private Product CreateProduct(XmlNode node)
 {
     bool flag = false;
     string str = this.ReadAttribute(node, "ProductCode");
     Product product = null;
     if (!string.IsNullOrEmpty(str))
     {
         ProductValidationResults validationResults = (ProductValidationResults) this.validationResults[str];
         XmlNode node2 = node.SelectSingleNode("bootstrapper:Package/bootstrapper:PackageFiles", this.xmlNamespaceManager);
         string copyAll = string.Empty;
         if (node2 != null)
         {
             copyAll = this.ReadAttribute(node2, "CopyAllPackageFiles");
         }
         product = new Product(node, str, validationResults, copyAll);
         foreach (XmlNode node3 in node.SelectNodes("bootstrapper:Package", this.xmlNamespaceManager))
         {
             Package package = this.CreatePackage(node3, product);
             if (package != null)
             {
                 product.AddPackage(package);
                 flag = true;
             }
         }
     }
     if (flag)
     {
         return product;
     }
     return null;
 }
 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);
         }
     }
 }
 private Package CreatePackage(XmlNode node, Product product)
 {
     string culture = this.ReadAttribute(node, "Culture");
     if (culture != null)
     {
         return new Package(product, node, product.GetPackageValidationResults(culture), this.ReadAttribute(node, "Name"), this.ReadAttribute(node, "Culture"));
     }
     return null;
 }
 private void AddIncludes(Product p, Hashtable availableProducts)
 {
     foreach (string str in this.SelectRelatedProducts(p, "IncludesProduct"))
     {
         if (availableProducts.Contains(str))
         {
             p.Includes.Add((Product) availableProducts[str]);
         }
     }
 }
 private string[] SelectRelatedProducts(Product p, string nodeName)
 {
     ArrayList list = new ArrayList();
     XmlNodeList list2 = p.Node.SelectNodes(string.Format(CultureInfo.InvariantCulture, "{0}:Package/{1}:RelatedProducts/{2}:{3}", new object[] { "bootstrapper", "bootstrapper", "bootstrapper", nodeName }), this.xmlNamespaceManager);
     if (list2 != null)
     {
         foreach (XmlNode node in list2)
         {
             XmlAttribute namedItem = (XmlAttribute) node.Attributes.GetNamedItem("Code");
             if (namedItem != null)
             {
                 list.Add(namedItem.Value);
             }
         }
     }
     string[] array = new string[list.Count];
     list.CopyTo(array, 0);
     return array;
 }
 private void AddIncludes(Product p, Hashtable availableProducts)
 {
     foreach (string relatedProductCode in SelectRelatedProducts(p, "IncludesProduct"))
     {
         if (availableProducts.Contains(relatedProductCode))
         {
             p.Includes.Add((Product)availableProducts[relatedProductCode]);
         }
     }
 }
 private Dictionary<string, Product> GetIncludedProducts(Product product)
 {
     Dictionary<string, Product> includedProducts = new Dictionary<string, Product>(StringComparer.OrdinalIgnoreCase);
     includedProducts.Add(product.ProductCode, product);
     foreach (Product product2 in product.Includes)
     {
         this.AddIncludedProducts(product2, includedProducts);
     }
     includedProducts.Remove(product.ProductCode);
     return includedProducts;
 }
        private string[] SelectRelatedProducts(Product p, string nodeName)
        {
            ArrayList list = new ArrayList();

            XmlNodeList relatedProducts = p.Node.SelectNodes(string.Format(CultureInfo.InvariantCulture, "{0}:Package/{1}:RelatedProducts/{2}:{3}", BOOTSTRAPPER_PREFIX, BOOTSTRAPPER_PREFIX, BOOTSTRAPPER_PREFIX, nodeName), _xmlNamespaceManager);
            if (relatedProducts != null)
            {
                foreach (XmlNode relatedProduct in relatedProducts)
                {
                    XmlAttribute relatedProductAttribute = (XmlAttribute)(relatedProduct.Attributes.GetNamedItem("Code"));
                    if (relatedProductAttribute != null)
                    {
                        list.Add(relatedProductAttribute.Value);
                    }
                }
            }

            string[] a = new string[list.Count];
            list.CopyTo(a, 0);
            return a;
        }
 private void RemoveDependency(Hashtable availableProducts, Product product)
 {
     Predicate<Product> match = null;
     foreach (Product product2 in availableProducts.Values)
     {
         foreach (List<Product> list in product2.Dependencies)
         {
             if (match == null)
             {
                 match = m => m == product;
             }
             list.RemoveAll(match);
         }
         product2.Dependencies.RemoveAll(m => m.Count == 0);
     }
 }
 private void RemoveDependency(Hashtable availableProducts, Product product)
 {
     foreach (Product p in availableProducts.Values)
     {
         foreach (List<Product> dependency in p.Dependencies)
         {
             dependency.RemoveAll(m => m == product);
         }
         p.Dependencies.RemoveAll(m => m.Count == 0);
     }
 }
Exemple #23
0
 internal ProductBuilder(Product product)
 {
     _product = product;
     _culture = string.Empty;
 }
Exemple #24
0
 internal void AddDependentProduct(Product product)
 {
     List<Product> newDependency = new List<Product>();
     newDependency.Add(product);
     _dependencies.Add(newDependency);
 }
Exemple #25
0
 internal ProductBuilder(Product product, string culture)
 {
     _product = product;
     _culture = culture;
 }