// System.Configuration.PositiveTimeSpanValidator.cs
//
// Authors:
-// Lluis Sanchez Gual (lluis@novell.com)
+// Chris Toshok (toshok@ximian.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
//
#if NET_2_0
+using System;
namespace System.Configuration
{
public class PositiveTimeSpanValidator: ConfigurationValidatorBase
{
- public override bool CanValidate (Type t)
+ public PositiveTimeSpanValidator ()
{
- return t == typeof(TimeSpan);
- }
+ }
+ public override bool CanValidate (Type type)
+ {
+ return type == typeof(TimeSpan);
+ }
+
public override void Validate (object value)
{
- if (((TimeSpan)value).Ticks <= 0)
- throw new ConfigurationErrorsException ("TimeSpan value must be positive.");
+ TimeSpan s = (TimeSpan) value;
+ if (s <= new TimeSpan (0))
+ throw new ArgumentException ("The time span value must be positive");
}
}
}
+
#endif