|
|
|
|
using System.Globalization;
|
|
|
|
|
using Connected.Interop.Reflection;
|
|
|
|
|
|
|
|
|
|
namespace Connected.Interop;
|
|
|
|
|
|
|
|
|
|
public static class TypeConversion
|
|
|
|
|
{
|
|
|
|
|
public static bool TryConvertInvariant<T>(object? value, out T? result)
|
|
|
|
|
{
|
|
|
|
|
return TypeConverter.TryConvertInvariant(value, out result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool TryConvertInvariant(object? value, out object? result, Type destinationType)
|
|
|
|
|
{
|
|
|
|
|
return TypeConverter.TryConvert(value, destinationType, out result, CultureInfo.InvariantCulture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool TryConvert(object? value, out object? result, Type destinationType)
|
|
|
|
|
{
|
|
|
|
|
return TypeConverter.TryConvert(value, destinationType, out result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool TryConvert<T>(object? value, out T? result)
|
|
|
|
|
{
|
|
|
|
|
return TypeConverter.TryConvertTo(value, out result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool TryConvert<T>(object? value, out T? result, CultureInfo culture)
|
|
|
|
|
{
|
|
|
|
|
return TypeConverter.TryConvertTo(value, out result, culture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static T? Convert<T>(object? value)
|
|
|
|
|
{
|
|
|
|
|
return TypeConverter.ConvertTo<T>(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static object? Convert(object? value, Type destinationType)
|
|
|
|
|
{
|
|
|
|
|
return TypeConverter.Convert(value, destinationType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static T? Convert<T>(object? value, CultureInfo culture)
|
|
|
|
|
{
|
|
|
|
|
return TypeConverter.ConvertTo<T>(value, culture);
|
|
|
|
|
}
|
|
|
|
|
}
|