Beispiel #1
0
 public static IEnumerable <S> Convert <S>(this IEnumerable <string> elements) where S : struct
 {
     foreach (var s in elements)
     {
         yield return(GenericTypeConverter.GetConverter().Convert <S>(s));
     }
 }
Beispiel #2
0
 /// <summary>
 /// If the value is present, applies a convertion to the given string.
 /// If the value is not present, return Maybe.Nothing.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="value"></param>
 /// <returns></returns>
 public static Maybe <T> Convert <T>(this Maybe <string> value) where T : struct
 {
     if (!value.HasValue)
     {
         return(Maybe <T> .Nothing);
     }
     else
     {
         try
         {
             return(GenericTypeConverter.GetConverter().Convert <T>(value.Value).ToMaybe());
         }
         catch (ConverterException)
         {
             return(Maybe <T> .Nothing);
         }
     }
 }