看來ConfigurationElement
的TimeSpan
無法處理大於23:59:59的值。有沒有解決方法?子類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
我的眼睛一定已經釉過了 – BozoJoe 2010-06-30 00:27:02