Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / TimeSpanValidator.cs / 1305376 / TimeSpanValidator.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.IO; using System.Reflection; using System.Security.Permissions; using System.Xml; using System.Collections.Specialized; using System.Globalization; using System.ComponentModel; using System.Security; using System.Text; using System.Text.RegularExpressions; namespace System.Configuration { public class TimeSpanValidator : ConfigurationValidatorBase { private enum ValidationFlags { None = 0x0000, ExclusiveRange = 0x0001, // If set the value must be outside of the range instead of inside } private ValidationFlags _flags = ValidationFlags.None; private TimeSpan _minValue = TimeSpan.MinValue; private TimeSpan _maxValue = TimeSpan.MaxValue; private long _resolution = 0; public TimeSpanValidator(TimeSpan minValue, TimeSpan maxValue) : this(minValue, maxValue, false, 0) { } public TimeSpanValidator(TimeSpan minValue, TimeSpan maxValue, bool rangeIsExclusive) : this(minValue, maxValue, rangeIsExclusive, 0) { } public TimeSpanValidator(TimeSpan minValue, TimeSpan maxValue, bool rangeIsExclusive, long resolutionInSeconds) { if (resolutionInSeconds < 0) { throw new ArgumentOutOfRangeException("resolutionInSeconds"); } if (minValue > maxValue) { throw new ArgumentOutOfRangeException("minValue", SR.GetString(SR.Validator_min_greater_than_max)); } _minValue = minValue; _maxValue = maxValue; _resolution = resolutionInSeconds; _flags = rangeIsExclusive ? ValidationFlags.ExclusiveRange : ValidationFlags.None; } public override bool CanValidate(Type type) { return (type == typeof(TimeSpan)); } public override void Validate(object value) { ValidatorUtils.HelperParamValidation(value, typeof(TimeSpan)); ValidatorUtils.ValidateScalar((TimeSpan)value, _minValue, _maxValue, _resolution, _flags == ValidationFlags.ExclusiveRange); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SqlTopReducer.cs
- SubclassTypeValidator.cs
- Attributes.cs
- fixedPageContentExtractor.cs
- ResourceDictionaryCollection.cs
- Keyboard.cs
- COM2ExtendedUITypeEditor.cs
- WeakEventManager.cs
- ServiceControllerDesigner.cs
- WsrmFault.cs
- COM2PropertyPageUITypeConverter.cs
- ADConnectionHelper.cs
- dbdatarecord.cs
- SolidBrush.cs
- PagedDataSource.cs
- CodeDirectionExpression.cs
- DbModificationCommandTree.cs
- ProcessHost.cs
- NativeMethods.cs
- MaskedTextBoxDesignerActionList.cs
- EventLogger.cs
- ExternalException.cs
- DataGridColumnHeaderItemAutomationPeer.cs
- BlockCollection.cs
- EdmSchemaError.cs
- BaseDataList.cs
- Timer.cs
- TextEditorThreadLocalStore.cs
- _ScatterGatherBuffers.cs
- MsdtcWrapper.cs
- ObjectQuery_EntitySqlExtensions.cs
- SafeRightsManagementQueryHandle.cs
- IconConverter.cs
- SymbolResolver.cs
- Geometry3D.cs
- EpmAttributeNameBuilder.cs
- ExportFileRequest.cs
- BoolExpression.cs
- DocumentViewerHelper.cs
- PlanCompilerUtil.cs
- XmlArrayAttribute.cs
- DocumentGridPage.cs
- ParsedAttributeCollection.cs
- ImageFormat.cs
- GestureRecognizer.cs
- Keyboard.cs
- CredentialManagerDialog.cs
- ReceiveReply.cs
- TextProperties.cs
- DiscoveryClientReferences.cs
- ServiceChannelManager.cs
- PageWrapper.cs
- FocusTracker.cs
- UdpDiscoveryEndpoint.cs
- SoapReflectionImporter.cs
- XmlHelper.cs
- CatalogPart.cs
- Tokenizer.cs
- FixedTextBuilder.cs
- ContextStaticAttribute.cs
- IsolatedStorageFileStream.cs
- UInt16Storage.cs
- WindowsSlider.cs
- MultiDataTrigger.cs
- GridViewHeaderRowPresenter.cs
- TdsParserSafeHandles.cs
- SelectorAutomationPeer.cs
- EntityProviderFactory.cs
- Int16Animation.cs
- AlphaSortedEnumConverter.cs
- Publisher.cs
- StringArrayConverter.cs
- SessionStateContainer.cs
- BatchParser.cs
- CompositionTarget.cs
- ListView.cs
- MessageFault.cs
- DataGridTable.cs
- SmtpClient.cs
- NumericExpr.cs
- EncryptedPackageFilter.cs
- ActivationArguments.cs
- EncryptedHeaderXml.cs
- FileDialog.cs
- ResourceReferenceKeyNotFoundException.cs
- ClientConfigPaths.cs
- RSAOAEPKeyExchangeFormatter.cs
- XmlSchemaAttributeGroupRef.cs
- WebServiceResponseDesigner.cs
- VisualSerializer.cs
- RandomNumberGenerator.cs
- TreeNodeCollection.cs
- odbcmetadatacollectionnames.cs
- SettingsProperty.cs
- DataSourceUtil.cs
- AttachedAnnotationChangedEventArgs.cs
- XPathParser.cs
- AttributeEmitter.cs
- GeneralTransform3D.cs
- FixedLineResult.cs