private object Parse(CachedProperty property, string unparsedValue, PropertyConfigurationAttribute propertyConfiguration) { var parser = GetParser(property.PropertyType, property.Name); object value; if (propertyConfiguration.AcceptInvalid) { value = parser.TryParse(unparsedValue, propertyConfiguration.DefaultValue); } else { value = parser.Parse(unparsedValue); } return(value); }
private object GetParsedValue <T>(CachedProperty property, string unparsedValue, PropertyConfigurationAttribute propertyConfiguration) where T : class { object value; if (unparsedValue == null) { if (propertyConfiguration.IsMandatory) { throw new MissingMandatoryConfigurationException(typeof(T), property.Name); } value = propertyConfiguration.DefaultValue; } else { value = Parse(property, unparsedValue, propertyConfiguration); } return(value); }