/// <summary>
 /// Get converter, throws exception if not found
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public IStringConverter GetConverter(Type type)
 {
     if (TryGetConverter(type, out var converter))
     {
         return(converter);
     }
     throw ConvertException.From(type);
 }
Esempio n. 2
0
 /// <summary>
 /// Creates a converter that always throws
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static IStringConverter Empty(Type type)
 {
     return(new StringConverter(
                type,
                e => throw ConvertException.From(type),
                e => throw ConvertException.From(type)
                ));
 }
 /// <summary>
 /// Get converter, throws exception if not found
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public IStringConverter <T> GetConverter <T>()
 {
     if (TryGetConverter <T>(out var converter))
     {
         return(converter);
     }
     throw ConvertException.From <T>();
 }
Esempio n. 4
0
        /// <summary>
        /// Creates a converter that always throws
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static IStringConverter <T> Empty <T>()
        {
            var type = typeof(T);

            return(new StringConverter <T>(
                       e => throw ConvertException.From <T>(),
                       e => throw ConvertException.From <T>()
                       ));
        }