/// <summary> /// Update all the writeable properties in the class. /// </summary> private void PopulatePropertiesFromConfiguration() { foreach (PropertyInfo propertyInfo in this.GetType().GetProperties().Where(p => p.CanWrite)) { string configKey = GetPropertyConfigKey(propertyInfo); try { string rawSettingValue = _configurationReader.GetSettingValue(configKey); string decryptedValue = _configurationDecryptor.DecryptAllSecrets(rawSettingValue); object convertedObject = ConvertValueToPropertyType(propertyInfo, decryptedValue); propertyInfo.SetValue(this, convertedObject, null); } catch (Exception ex) { throw new ArgumentException($"Failed initializing property: {propertyInfo.Name}, from config key: {configKey}, with exception: {ex}"); } } }