private static bool TryGetValue(PropertyInfo propertyInfo, Configuration configuration, out object result) { result = null; var type = propertyInfo.PropertyType; var reflectedType = propertyInfo.ReflectedType; var keys = new[] { reflectedType.Name + propertyInfo.Name, propertyInfo.Name, }; var vals = from key in keys let attempt = type == typeof(ConnectionStringSettings) ? configuration.ConnectionString.Get(key) : configuration.ConvertValue(type, configuration.Get(key)) where attempt != null select attempt; foreach (var value in vals) { result = value; return(true); } return(false); }
private static object GetValueOrNull(Type type, string key, Configuration configuration) { try { return(type == typeof(ConnectionStringSettings) ? configuration.ConnectionString.Get(key) : configuration.ConvertValue(type, configuration.Get(key))); } catch (InvalidOperationException) { return(null); } }