public RegistryConfigurationInstance(bool isReadOnly, ConfigurationServiceConfig config) : base(isReadOnly, config) { var softwareKey = Registry.CurrentUser.OpenSubKey("Software", !isReadOnly); var companyKey = softwareKey.OpenSubKey(config.CompanyName, !isReadOnly); if (!isReadOnly) { companyKey = softwareKey.CreateSubKey(config.CompanyName); } if (companyKey != null) { _rootKey = companyKey.OpenSubKey(config.ProductName, !isReadOnly); if (!isReadOnly && _rootKey == null) { _rootKey = companyKey.CreateSubKey(config.ProductName); } } }
public XMLConfigurationInstance(bool isReadOnly, ConfigurationServiceConfig config) : base(isReadOnly, config) { _profilePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); _doc = new XmlDocument(); string filePath = SettingsFilePath; if (File.Exists(filePath)) { try { _doc.Load(filePath); } catch { _doc.RemoveAll(); } } _rootNode = null; XmlNode companyNode = _doc.SelectSingleNode($"/{config.CompanyName}"); XmlNode productNode = null; if (companyNode != null) { productNode = companyNode.SelectSingleNode($"{config.ProductName}"); } if (!IsReadOnly) { if (companyNode == null) { companyNode = _doc.CreateElement(config.CompanyName); _doc.AppendChild(companyNode); } if (productNode == null) { productNode = _doc.CreateElement(config.ProductName); companyNode.AppendChild(productNode); } } _rootNode = productNode; }
public IConfigurarionInstance Create(bool readOnly, ConfigurationServiceConfig config) { RegistryConfigurationInstance result = new RegistryConfigurationInstance(readOnly, config); return(result); }
public BaseConfigurationInstance(bool isReadOnly, ConfigurationServiceConfig config) { IsReadOnly = isReadOnly; Config = config; }