Exemple #1
0
        public void SetValue(Option option, object model, IList <string> values, IFormatProvider formatProvider)
        {
            if (!option.Type.IsList() && values.Count > 1)
            {
                throw new MultipleValueForNotCollectionTypeException(option.ToString(), values.Count);
            }

            try
            {
                SetValue(option, model, _valueConverterFactory.Convert(values, option.Type, formatProvider));
            }
            catch (Exception e) when(e is FormatException || e is OverflowException ||
                                     e is ArgumentOutOfRangeException)
            {
                throw new InvalidOptionValueException(option.ToString(), values);
            }
        }
Exemple #2
0
 internal void ValueConverterFactory_Convert_ListNullableTypes(Type type)
 {
     Assert.IsType(type, _valueConverterFactory.Convert(
                       Array.Empty <string>(), type, CultureInfo.InvariantCulture));
 }