/// <summary>
        /// Gets a root registry key, based on its name (eg, HKEY_CURRENT_USER or HKCU).
        /// </summary>
        /// <param name="rootKeyName">The root key name.</param>
        /// <param name="registry"></param>
        public static IRegistryKey GetRootKey(string rootKeyName, IRegistry registry)
        {
            RegistryHive registryHive;

            switch (rootKeyName.ToUpperInvariant())
            {
            case "HKEY_CLASSES_ROOT":
            case "HKCR":
                registryHive = RegistryHive.ClassesRoot;
                break;

            case "HKEY_CURRENT_CONFIG":
            case "HKCC":
                registryHive = RegistryHive.CurrentConfig;
                break;

            case "HKEY_CURRENT_USER":
            case "HKCU":
                registryHive = RegistryHive.CurrentUser;
                break;

            case "HKEY_LOCAL_MACHINE":
            case "HKLM":
                registryHive = RegistryHive.LocalMachine;
                break;

            case "HKEY_PERFORMANCE_DATA":
                registryHive = RegistryHive.PerformanceData;
                break;

            case "HKEY_USERS":
            case "HKU":
                registryHive = RegistryHive.Users;
                break;

            default:
                throw new InvalidOperationException($"Unrecognised hKey value {rootKeyName}");
            }

            return(registry.OpenBaseKey(registryHive, RegistryView.Default));
        }
 public RegistrySettingsHandler(IServiceProvider serviceProvider, IRegistry registry)
 {
     this.serviceProvider = serviceProvider;
     this.registry        = registry;
 }