public void SaveConfiguration(XDConfig.Configuration configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("The configuration object is null.");
            }

            // Check and remove old key to clean up
            RegistryKey rootRegistryKey   = RegistryConfigurationProcessor.GetRegistryKey(String.Empty, this.Scope);
            RegistryKey configRegistryKey = rootRegistryKey.OpenSubKey(this.RootPath); // Read-only

            if (configRegistryKey != null)
            {
                configRegistryKey.Close();

                rootRegistryKey.DeleteSubKeyTree(this.RootPath);
            }

            configRegistryKey = RegistryConfigurationProcessor.GetRegistryKey(this.RootPath, this.Scope);

            foreach (XDConfig.ConfigurationSection section in configuration.Sections)
            {
                RegistryKey sectionRegistryKey = RegistryConfigurationProcessor.GetRegistryKey(Path.Combine(this.RootPath, section.Name), this.Scope);

                foreach (KeyValuePair <String, String> pair in section)
                {
                    sectionRegistryKey.SetValue(pair.Key, pair.Value);
                }

                sectionRegistryKey.Close();
            }

            configRegistryKey.Close();
        }
        public XDConfig.Configuration LoadConfiguration()
        {
            XDConfig.Configuration configuration = new XDConfig.Configuration();

            if (this.CheckConfiguration())
            {
                RegistryKey configRegistryKey = RegistryConfigurationProcessor.GetRegistryKey(this.RootPath, this.Scope);

                foreach (String sectionName in configRegistryKey.GetSubKeyNames())
                {
                    configuration.AddSection(sectionName);

                    RegistryKey sectionRegistryKey = RegistryConfigurationProcessor.GetRegistryKey(Path.Combine(this.RootPath, sectionName), this.Scope);

                    foreach (String key in sectionRegistryKey.GetValueNames())
                    {
                        configuration[sectionName].Add(key, sectionRegistryKey.GetValue(key).ToString());
                    }

                    sectionRegistryKey.Close();
                }

                configRegistryKey.Close();
            }

            return(configuration);
        }
        public Boolean CheckConfiguration()
        {
            RegistryKey rootRegistryKey   = RegistryConfigurationProcessor.GetRegistryKey(String.Empty, this.Scope);
            RegistryKey configRegistryKey = rootRegistryKey.OpenSubKey(this.RootPath);

            Boolean result = (configRegistryKey != null);

            configRegistryKey?.Close();

            return(result);
        }