似乎无法处理大于 23:59:59ConfigurationElement
的值。TimeSpan
有什么解决方法吗?子类化TimeSpan
和制作新的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