You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
48 lines
1.3 KiB
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);
|
|
}
|
|
}
|