TimeSpanConverter
using Castle.Core.Configuration;
using System;
namespace Castle.MicroKernel.SubSystems.Conversion
{
[Serializable]
public class TimeSpanConverter : AbstractTypeConverter
{
public override bool CanHandleType(Type type)
{
return type == typeof(TimeSpan);
}
public override object PerformConversion(string value, Type targetType)
{
try {
return TimeSpan.Parse(value);
} catch (Exception innerException) {
throw new ConverterException($"""{value}""{targetType.FullName}", innerException);
}
}
public override object PerformConversion(IConfiguration configuration, Type targetType)
{
return PerformConversion(configuration.get_Value(), targetType);
}
}
}