看来
ConfigurationElement
TimeSpan
无法处理大于23:59:59的值。有解决方法吗?是子类化的
,并制作一个新的
TimeSpanValidatorAttribute
甚至去上班?我需要处理从几分钟到几天的时间跨度。
我正在使用以下配置部分
[ConfigurationProperty("SequenceRolloverDOSCompare", IsRequired = true)]
[TimeSpanValidator(MinValueString = "0:0:00", MaxValueString = 10675199.02:48:05.4775807", ExcludeRange = false)]
public TimeSpan SequenceRolloverDOSCompare
{
get
{
return (TimeSpan)base["SequenceRolloverDOSCompare"];
}
}
配置如下:
<SequenceRolloverPolling SequenceRolloverDOSCompare="2:00:00:00" />
给予
ConfigurationErrorsException : The value of the property 'SequenceRolloverDOSCompare' cannot be parsed. The error is: 2:00:00:00 is not a valid value for TimeSpan.
<SequenceRolloverPolling SequenceRolloverDOSCompare="48:00:00" />
给予
OverflowException : The TimeSpan could not be parsed because at least one of the hours, minutes, or seconds components is outside its valid range