System.Xml.XmlReaderSettings.ReadSettingsFromRegistry C# (CSharp) Méthode

ReadSettingsFromRegistry() private méthode

private ReadSettingsFromRegistry ( RegistryKey hive, bool &value ) : bool
hive Microsoft.Win32.RegistryKey
value bool
Résultat bool
        private static bool ReadSettingsFromRegistry(RegistryKey hive, ref bool value)
        {
            const string regValueName = "EnableLegacyXmlSettings";
            const string regValuePath = @"SOFTWARE\Microsoft\.NETFramework\XML";

            try
            {
                using (RegistryKey xmlRegKey = hive.OpenSubKey(regValuePath, false))
                {
                    if (xmlRegKey != null)
                    {
                        if (xmlRegKey.GetValueKind(regValueName) == RegistryValueKind.DWord)
                        {
                            value = ((int)xmlRegKey.GetValue(regValueName)) == 1;
                            return true;
                        }
                    }
                }
            }
            catch { /* use the default if we couldn't read the key */ }

            return false;
        }
    }