Inheritance: IProductCollection
示例#1
0
        /// <summary>
        /// Finds all products installed on the system with given product name
        /// search pattern and file name search pattern. e.g. to find Dynamo
        /// installations, we can use Dynamo as product search pattern and
        /// DynamoCore.dll as file search pattern.
        /// </summary>
        /// <param name="productSearchPattern">search key for product</param>
        /// <param name="fileSearchPattern">search key for files</param>
        /// <returns>List of KeyValuePair of product install location and 
        /// version info as Tuple of the file found in the installation based 
        /// on file search pattern. The returned list is sorted based on version 
        /// info.</returns>
        public static IEnumerable FindProductInstallations(string productSearchPattern, string fileSearchPattern)
        {
            var installs = new InstalledProducts();
            installs.LookUpAndInitProducts(new InstalledProductLookUp(productSearchPattern, fileSearchPattern));

            return
                installs.Products.Select(
                    p =>
                        new KeyValuePair<string, Tuple<int, int, int, int>>(
                        p.InstallLocation,
                        p.VersionInfo));
        }
示例#2
0
        /// <summary>
        /// Finds all products installed on the system with given product name
        /// search pattern and file name search pattern. e.g. to find Dynamo
        /// installations, we can use Dynamo as product search pattern and
        /// DynamoCore.dll as file search pattern.
        /// </summary>
        /// <param name="productSearchPattern">search key for product</param>
        /// <param name="fileSearchPattern">search key for files</param>
        /// <returns>List of KeyValuePair of product install location and
        /// version info as Tuple of the file found in the installation based
        /// on file search pattern. The returned list is sorted based on version
        /// info.</returns>
        public static IEnumerable FindProductInstallations(string productSearchPattern, string fileSearchPattern)
        {
            var installs = new InstalledProducts();

            installs.LookUpAndInitProducts(new InstalledProductLookUp(productSearchPattern, fileSearchPattern));

            return
                (installs.Products.Select(
                     p =>
                     new KeyValuePair <string, Tuple <int, int, int, int> >(
                         p.InstallLocation,
                         p.VersionInfo)));
        }
示例#3
0
        /// <summary>
        /// Finds all products installed on the system with given product name
        /// search pattern and file name search pattern. e.g. to find Dynamo
        /// installations, we can use Dynamo as product search pattern and
        /// DynamoCore.dll as file search pattern.
        /// </summary>
        /// <param name="productSearchPattern">search keys for product</param>
        /// <param name="fileSearchPattern">search key for files</param>
        /// <returns>List of KeyValuePair of product install location and
        /// version info as Tuple of the file found in the installation based
        /// on file search pattern. The returned list is sorted based on version
        /// info.</returns>
        public static IEnumerable FindMultipleProductInstallations(List <string> productSearchPatterns, string fileSearchPattern)
        {
            var installs = new InstalledProducts();

            // Look up products with ASM installed on user's computer
            foreach (var productSearchPattern in productSearchPatterns)
            {
                installs.LookUpAndInitProducts(new InstalledProductLookUp(productSearchPattern, fileSearchPattern));
            }

            return
                (installs.Products.Select(
                     p =>
                     new KeyValuePair <string, Tuple <int, int, int, int> >(
                         p.InstallLocation,
                         p.VersionInfo)));
        }
示例#4
0
        public void GetInstalledProducts()
        {
            var products = new Dictionary<string, Tuple<int, int, int, int>>
            {
                { "A", Tuple.Create(0, 1, 2, 3) },
                { "B", Tuple.Create(0, 1, 3, 4) },
                { "C", Tuple.Create(1, 2, 3, 4) },
                { "D", Tuple.Create(1, 0, 3, 4) },
                { "E", null }
            };
            var lookUp = SetUpProductLookUp(products, null);

            var p = new InstalledProducts();
            p.LookUpAndInitProducts(lookUp);

            Assert.AreEqual("C", p.GetLatestProduct().ProductName);
            Assert.AreEqual("1.2.3.4", p.GetLatestProduct().VersionString);
            Assert.AreEqual(4, p.Products.Count());
        }