private void SetPropertyValue(object automationObject, string propertyName, RegistryKey registryKey) { var property = automationObject.GetType().GetProperty(propertyName); if(property == null) { return; } if(property.GetCustomAttribute(typeof(TypeConverterAttribute)) == null) { return; } var storedValue = registryKey.GetValue(propertyName).ToString(); var converter = new SerializableConverter<BindingList<XPathSetting>>(); property.SetValue(automationObject, converter.ConvertFrom(storedValue)); }
private void SaveCollectionToRegistry(RegistryKey userRegistryRoot, string propertyName, BindingList<XPathSetting> settings) { var settingsRegistryPath = SettingsRegistryPath; var registryKey = userRegistryRoot.OpenSubKey(settingsRegistryPath, true) ?? userRegistryRoot.CreateSubKey(settingsRegistryPath); using(registryKey) { var converter = new SerializableConverter<BindingList<XPathSetting>>(); var convertedValue = converter.ConvertTo(settings, typeof(string)); registryKey.SetValue(propertyName, convertedValue); } }