mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 17:02:51 +08:00
15 lines
415 B
C#
15 lines
415 B
C#
namespace Spectre.Console.Tests.Data;
|
|
|
|
public sealed class StringToIntegerConverter : TypeConverter
|
|
{
|
|
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
|
{
|
|
if (value is string stringValue)
|
|
{
|
|
return int.Parse(stringValue, CultureInfo.InvariantCulture);
|
|
}
|
|
|
|
return base.ConvertFrom(context, culture, value);
|
|
}
|
|
}
|