Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }