Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Configuration / System / Configuration / LongValidator.cs / 1 / LongValidator.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 LongValidator : 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 long _minValue = long.MinValue; private long _maxValue = long.MaxValue; private long _resolution = 1; public LongValidator(long minValue, long maxValue) : this(minValue, maxValue, false, 1) { } public LongValidator(long minValue, long maxValue, bool rangeIsExclusive) : this(minValue, maxValue, rangeIsExclusive, 1) { } public LongValidator(long minValue, long maxValue, bool rangeIsExclusive, long resolution) { if (resolution <= 0) { throw new ArgumentOutOfRangeException("resolution"); } if (minValue > maxValue) { throw new ArgumentOutOfRangeException("minValue", SR.GetString(SR.Validator_min_greater_than_max)); } _minValue = minValue; _maxValue = maxValue; _resolution = resolution; _flags = rangeIsExclusive ? ValidationFlags.ExclusiveRange : ValidationFlags.None; } public override bool CanValidate(Type type) { return (type == typeof(long)); } public override void Validate(object value) { ValidatorUtils.HelperParamValidation(value, typeof(long)); ValidatorUtils.ValidateScalar((long)value, _minValue, _maxValue, _resolution, _flags == ValidationFlags.ExclusiveRange); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// 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 LongValidator : 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 long _minValue = long.MinValue; private long _maxValue = long.MaxValue; private long _resolution = 1; public LongValidator(long minValue, long maxValue) : this(minValue, maxValue, false, 1) { } public LongValidator(long minValue, long maxValue, bool rangeIsExclusive) : this(minValue, maxValue, rangeIsExclusive, 1) { } public LongValidator(long minValue, long maxValue, bool rangeIsExclusive, long resolution) { if (resolution <= 0) { throw new ArgumentOutOfRangeException("resolution"); } if (minValue > maxValue) { throw new ArgumentOutOfRangeException("minValue", SR.GetString(SR.Validator_min_greater_than_max)); } _minValue = minValue; _maxValue = maxValue; _resolution = resolution; _flags = rangeIsExclusive ? ValidationFlags.ExclusiveRange : ValidationFlags.None; } public override bool CanValidate(Type type) { return (type == typeof(long)); } public override void Validate(object value) { ValidatorUtils.HelperParamValidation(value, typeof(long)); ValidatorUtils.ValidateScalar((long)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
- tabpagecollectioneditor.cs
- OpCodes.cs
- ContextQuery.cs
- DesignerSerializationOptionsAttribute.cs
- UnsafeNativeMethods.cs
- SessionStateItemCollection.cs
- ContextProperty.cs
- MarkerProperties.cs
- _DynamicWinsockMethods.cs
- SetStateDesigner.cs
- PrintDialog.cs
- HtmlElementErrorEventArgs.cs
- AutomationPatternInfo.cs
- TypefaceMetricsCache.cs
- UriTemplateCompoundPathSegment.cs
- WebControlAdapter.cs
- PageSetupDialog.cs
- NumberFormatInfo.cs
- ParseHttpDate.cs
- InternalConfigConfigurationFactory.cs
- EnumUnknown.cs
- Adorner.cs
- CompositeActivityDesigner.cs
- XmlStreamedByteStreamReader.cs
- MultiDataTrigger.cs
- DetailsViewDeletedEventArgs.cs
- ImmutableAssemblyCacheEntry.cs
- MatrixCamera.cs
- WorkflowPersistenceService.cs
- CompositeKey.cs
- EntityTypeBase.cs
- XmlStreamStore.cs
- OletxDependentTransaction.cs
- AssertSection.cs
- WizardStepBase.cs
- UidManager.cs
- TextTabProperties.cs
- IUnknownConstantAttribute.cs
- OptimalBreakSession.cs
- InkCanvasSelectionAdorner.cs
- ISCIIEncoding.cs
- IResourceProvider.cs
- SizeChangedInfo.cs
- MaterialGroup.cs
- EncryptedData.cs
- hebrewshape.cs
- StretchValidation.cs
- TraceRecord.cs
- RangeBaseAutomationPeer.cs
- HtmlInputButton.cs
- NativeMethods.cs
- ValidatedControlConverter.cs
- ContentFilePart.cs
- SettingsBase.cs
- HttpBufferlessInputStream.cs
- Privilege.cs
- Misc.cs
- RuleSetBrowserDialog.cs
- COM2IVsPerPropertyBrowsingHandler.cs
- Mutex.cs
- Stacktrace.cs
- ConditionCollection.cs
- ListItemConverter.cs
- PersonalizationProvider.cs
- DataObjectMethodAttribute.cs
- SecurityTokenResolver.cs
- ListParagraph.cs
- SizeConverter.cs
- SecurityPolicySection.cs
- MenuItemBindingCollection.cs
- MultiView.cs
- ParseChildrenAsPropertiesAttribute.cs
- MessageLoggingElement.cs
- DesignTimeParseData.cs
- TextInfo.cs
- BindingMAnagerBase.cs
- Permission.cs
- Directory.cs
- AnnotationHelper.cs
- COM2PropertyBuilderUITypeEditor.cs
- RangeValidator.cs
- DynamicMethod.cs
- SchemaImporterExtensionElementCollection.cs
- SafeViewOfFileHandle.cs
- Array.cs
- __FastResourceComparer.cs
- Int32CAMarshaler.cs
- BasicViewGenerator.cs
- PropertyGridView.cs
- FilteredDataSetHelper.cs
- XmlDataSourceNodeDescriptor.cs
- DesignOnlyAttribute.cs
- IPAddress.cs
- SingleAnimationUsingKeyFrames.cs
- PaperSource.cs
- CommonGetThemePartSize.cs
- RenderingEventArgs.cs
- DesigntimeLicenseContext.cs
- _AutoWebProxyScriptHelper.cs
- QueryIntervalOp.cs