themed scroll bars, rounded courners, libmpv update
This commit is contained in:
33
src/WPF/HandyControl/Tools/Extension/StringExtension.cs
Normal file
33
src/WPF/HandyControl/Tools/Extension/StringExtension.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace HandyControl.Tools.Extension
|
||||
{
|
||||
public static class StringExtension
|
||||
{
|
||||
public static T Value<T>(this string input)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T) TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(input);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
public static object Value(this string input, Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
return TypeDescriptor.GetConverter(type).ConvertFromString(input);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user