PositiveTimeSpanValidator.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Configuration / System / Configuration / PositiveTimeSpanValidator.cs / 1 / PositiveTimeSpanValidator.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

using System; 
using System.Configuration; 
using System.ComponentModel;
 
namespace System.Configuration {

    public class PositiveTimeSpanValidator : ConfigurationValidatorBase {
        public override bool CanValidate(Type type) { 
            return (type == typeof(TimeSpan));
        } 
        public override void Validate(object value) { 
            if (value == null) {
                throw new ArgumentNullException("value"); 
            }

            if (((TimeSpan)value) <= TimeSpan.Zero) {
                throw new ArgumentException(SR.GetString(SR.Validator_timespan_value_must_be_positive)); 
            }
        } 
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

using System; 
using System.Configuration; 
using System.ComponentModel;
 
namespace System.Configuration {

    public class PositiveTimeSpanValidator : ConfigurationValidatorBase {
        public override bool CanValidate(Type type) { 
            return (type == typeof(TimeSpan));
        } 
        public override void Validate(object value) { 
            if (value == null) {
                throw new ArgumentNullException("value"); 
            }

            if (((TimeSpan)value) <= TimeSpan.Zero) {
                throw new ArgumentException(SR.GetString(SR.Validator_timespan_value_must_be_positive)); 
            }
        } 
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK