TimeSpanOrInfiniteValidator.cs 799 B

123456789101112131415161718192021222324252627
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.ServiceModel.Configuration
  5. {
  6. using System;
  7. using System.Configuration;
  8. class TimeSpanOrInfiniteValidator : TimeSpanValidator
  9. {
  10. public TimeSpanOrInfiniteValidator(TimeSpan minValue, TimeSpan maxValue)
  11. : base(minValue, maxValue)
  12. {
  13. }
  14. public override void Validate(object value)
  15. {
  16. if (value.GetType() == typeof(TimeSpan) && (TimeSpan)value == TimeSpan.MaxValue)
  17. {
  18. return; // we're good
  19. }
  20. base.Validate(value);
  21. }
  22. }
  23. }