public override void Validate(object value)
{
var data = (TimeSpan)value;
if (data == Timeout.InfiniteTimeSpan)
{
return;
}
var seconds = data.Ticks / 10000000L;
if (_exclude)
{
if (seconds > _minimum && seconds < _maximum && (seconds - _minimum) % _granularity != 0)
{
throw new COMException(
string.Format(
"Timespan value must not be between {0} and {1} seconds inclusive, with a granularity of {2} seconds\r\n",
TimeSpan.FromSeconds(_minimum),
TimeSpan.FromSeconds(_maximum),
_granularity));
}
}
else
{
if (seconds < _minimum || seconds > _maximum || (seconds - _minimum) % _granularity != 0)
{
if (_minimum != 1L || (seconds % _granularity != 0))
{
// IMPORTANT: workaround sessionState / timeout's definition using 1 issue.
throw new COMException(
string.Format(
"Timespan value must be between {0} and {1} seconds inclusive, with a granularity of {2} seconds\r\n",
TimeSpan.FromSeconds(_minimum),
TimeSpan.FromSeconds(_maximum),
_granularity));
}
}
}
}
}