Example #1
0
        public override bool Equals(object obj)
        {
            ObjectToken objectToken = obj as ObjectToken;

            if (objectToken != null)
            {
                return(string.Compare(base.Id, objectToken.Id, StringComparison.OrdinalIgnoreCase) == 0);
            }
            return(false);
        }
Example #2
0
        internal static ObjectToken DefaultToken(string category)
        {
            Helpers.ThrowIfEmptyOrNull(category, "category");
            ObjectToken objectToken = null;

            objectToken = DefaultToken("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Speech\\" + category, "DefaultTokenId");
            if (objectToken == null)
            {
                objectToken = DefaultToken("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech\\" + category, "DefaultTokenId");
            }
            return(objectToken);
        }
Example #3
0
 private static ObjectToken GetHighestTokenVersion(ObjectToken token, ObjectToken tokenSeed, string[] criterias)
 {
     if (tokenSeed.MatchesAttributes(criterias))
     {
         bool pfDidCompare;
         int  num = CompareTokenVersions(tokenSeed, token, out pfDidCompare);
         if (pfDidCompare && num > 0)
         {
             token = tokenSeed;
         }
     }
     return(token);
 }
Example #4
0
        private static ObjectToken DefaultToken(string category, string defaultTokenIdValueName)
        {
            ObjectToken objectToken = GetPreference(category, defaultTokenIdValueName);

            if (objectToken != null)
            {
                using (ObjectTokenCategory objectTokenCategory = ObjectTokenCategory.Create(category))
                {
                    if (objectTokenCategory == null)
                    {
                        return(objectToken);
                    }
                    if (objectToken != null)
                    {
                        foreach (ObjectToken item in (IEnumerable <ObjectToken>)objectTokenCategory)
                        {
                            objectToken = GetHighestTokenVersion(objectToken, item, asVersionDefault);
                        }
                        return(objectToken);
                    }
                    string[] sAttributes = new string[1]
                    {
                        string.Format(CultureInfo.InvariantCulture, "{0:x}", new object[1]
                        {
                            CultureInfo.CurrentUICulture.LCID
                        })
                    };
                    foreach (ObjectToken item2 in (IEnumerable <ObjectToken>)objectTokenCategory)
                    {
                        if (item2.MatchesAttributes(sAttributes))
                        {
                            objectToken = item2;
                            break;
                        }
                    }
                    if (objectToken == null)
                    {
                        using (IEnumerator <ObjectToken> enumerator3 = ((IEnumerable <ObjectToken>)objectTokenCategory).GetEnumerator())
                        {
                            if (enumerator3.MoveNext())
                            {
                                return(enumerator3.Current);
                            }
                            return(objectToken);
                        }
                    }
                    return(objectToken);
                }
            }
            return(objectToken);
        }
Example #5
0
        private static ObjectToken GetPreference(string category, string defaultLocation)
        {
            ObjectToken result = null;

            using (ObjectTokenCategory objectTokenCategory = ObjectTokenCategory.Create(category))
            {
                if (objectTokenCategory == null)
                {
                    return(result);
                }
                string value;
                if (objectTokenCategory.TryGetString(defaultLocation, out value))
                {
                    return(objectTokenCategory.OpenToken(value));
                }
                return(result);
            }
        }
Example #6
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);
        }