Esempio n. 1
0
 /// <summary>
 /// Converts the value to the specified type. If the value is unable to be converted, the
 /// value is checked whether it assignable to the specified type.
 /// </summary>
 /// <param name="initialValue">The value to convert.</param>
 /// <param name="culture">The culture to use when converting.</param>
 /// <param name="targetType">The type to convert the value to.</param>
 /// <param name="convertedValue">The converted value if the conversion was successful or the default value of <c>T</c> if it failed.</param>
 /// <returns>
 ///     <c>true</c> if <c>initialValue</c> was converted successfully or is assignable; otherwise, <c>false</c>.
 /// </returns>
 public static bool TryConvertOrCast(object initialValue, CultureInfo culture, Type targetType, out object convertedValue)
 {
     return(MiscellaneousUtils.TryAction <object>(delegate { return ConvertOrCast(initialValue, culture, targetType); }, out convertedValue));
 }
Esempio n. 2
0
 public static bool TryGetSingleItem <T>(IList <T> list, bool returnDefaultIfEmpty, out T value)
 {
     return(MiscellaneousUtils.TryAction <T>(delegate { return GetSingleItem(list, returnDefaultIfEmpty); }, out value));
 }