コード例 #1
0
        /// <summary>
        /// Takes two tokens and compares them using version info.
        /// Note only tokens that match on Vendor, ProductLine, Language get compared, the pfDidCompare flag indicates this
        /// </summary>
        private static int CompareTokenVersions(ObjectToken token1, ObjectToken token2, out bool pfDidCompare)
        {
            pfDidCompare = false;

            RegistryDataKey attributes1 = null;
            RegistryDataKey attributes2 = null;

            attributes1 = token1.Attributes;
            attributes2 = token2.Attributes;

            // get vendor, version, language, product line for token 1
            if (attributes1 != null)
            {
                string vendor1;
                string productLine1;
                string version1;
                string language1;
                attributes1.TryGetString("Vendor", out vendor1);
                attributes1.TryGetString("ProductLine", out productLine1);
                attributes1.TryGetString("Version", out version1);
                attributes1.TryGetString("Language", out language1);

                // get vendor, version, language, product line for token 2
                if (attributes2 != null)
                {
                    string vendor2;
                    string productLine2;
                    string version2;
                    string language2;
                    attributes2.TryGetString("Vendor", out vendor2);
                    attributes2.TryGetString("ProductLine", out productLine2);
                    attributes2.TryGetString("Version", out version2);
                    attributes2.TryGetString("Language", out language2);

                    if (((string.IsNullOrEmpty(vendor1) && string.IsNullOrEmpty(vendor2)) || (!string.IsNullOrEmpty(vendor1) && !string.IsNullOrEmpty(vendor2) && vendor1 == vendor2)) &&
                        ((string.IsNullOrEmpty(productLine1) && string.IsNullOrEmpty(productLine2)) || (!string.IsNullOrEmpty(productLine1) && !string.IsNullOrEmpty(productLine2) && productLine1 == productLine2)) &&
                        ((string.IsNullOrEmpty(language1) && string.IsNullOrEmpty(language2)) || (!string.IsNullOrEmpty(language1) && !string.IsNullOrEmpty(language2) && language1 == language2)))
                    {
                        pfDidCompare = true;
                        return(CompareVersions(version1, version2));
                    }
                    else
                    {
                        return(-1);
                    }
                }
                else
                {
                    return(1);
                }
            }
            else
            {
                return(-1);
            }
        }
コード例 #2
0
        private static int CompareTokenVersions(ObjectToken token1, ObjectToken token2, out bool pfDidCompare)
        {
            pfDidCompare = false;
            RegistryDataKey registryDataKey  = null;
            RegistryDataKey registryDataKey2 = null;

            registryDataKey  = token1.Attributes;
            registryDataKey2 = token2.Attributes;
            if (registryDataKey != null)
            {
                string value;
                registryDataKey.TryGetString("Vendor", out value);
                string value2;
                registryDataKey.TryGetString("ProductLine", out value2);
                string value3;
                registryDataKey.TryGetString("Version", out value3);
                string value4;
                registryDataKey.TryGetString("Language", out value4);
                if (registryDataKey2 != null)
                {
                    string value5;
                    registryDataKey2.TryGetString("Vendor", out value5);
                    string value6;
                    registryDataKey2.TryGetString("ProductLine", out value6);
                    string value7;
                    registryDataKey2.TryGetString("Version", out value7);
                    string value8;
                    registryDataKey2.TryGetString("Language", out value8);
                    if (((string.IsNullOrEmpty(value) && string.IsNullOrEmpty(value5)) || (!string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(value5) && value == value5)) && ((string.IsNullOrEmpty(value2) && string.IsNullOrEmpty(value6)) || (!string.IsNullOrEmpty(value2) && !string.IsNullOrEmpty(value6) && value2 == value6)) && ((string.IsNullOrEmpty(value4) && string.IsNullOrEmpty(value8)) || (!string.IsNullOrEmpty(value4) && !string.IsNullOrEmpty(value8) && value4 == value8)))
                    {
                        pfDidCompare = true;
                        return(CompareVersions(value3, value7));
                    }
                    return(-1);
                }
                return(1);
            }
            return(-1);
        }