Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / LongValidator.cs / 1305376 / 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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XPathAncestorQuery.cs
- Baml6Assembly.cs
- BaseUriHelper.cs
- MatrixStack.cs
- Profiler.cs
- DefaultHttpHandler.cs
- QilInvokeLateBound.cs
- ListItemParagraph.cs
- BamlMapTable.cs
- WebPartAuthorizationEventArgs.cs
- securitycriticaldata.cs
- propertytag.cs
- HttpPostedFileBase.cs
- DeviceSpecific.cs
- GridViewRow.cs
- XhtmlBasicSelectionListAdapter.cs
- FormatConvertedBitmap.cs
- RepeatButton.cs
- GeneralTransform3DTo2DTo3D.cs
- SmiContextFactory.cs
- CompilerError.cs
- SerialErrors.cs
- Int16.cs
- SmtpNegotiateAuthenticationModule.cs
- AttachInfo.cs
- Point3D.cs
- BaseTransportHeaders.cs
- OdbcParameterCollection.cs
- FrameworkContentElement.cs
- CalendarAutoFormatDialog.cs
- HttpResponse.cs
- IMembershipProvider.cs
- PaperSize.cs
- SectionUpdates.cs
- ProtocolException.cs
- _NestedMultipleAsyncResult.cs
- QilLoop.cs
- ConfigurationStrings.cs
- HtmlValidatorAdapter.cs
- QuaternionRotation3D.cs
- URIFormatException.cs
- SelectionItemProviderWrapper.cs
- xml.cs
- SchemaTypeEmitter.cs
- PtsPage.cs
- SystemResourceKey.cs
- NativeCompoundFileAPIs.cs
- LogLogRecordHeader.cs
- TextServicesProperty.cs
- SamlAssertionKeyIdentifierClause.cs
- SymmetricAlgorithm.cs
- XmlParserContext.cs
- DocumentScope.cs
- ExpressionBindingCollection.cs
- XmlnsPrefixAttribute.cs
- MessageBox.cs
- XmlLoader.cs
- ScrollProviderWrapper.cs
- ComPlusDiagnosticTraceSchemas.cs
- EntityContainerEmitter.cs
- Sorting.cs
- MatrixTransform3D.cs
- HtmlInputPassword.cs
- ClientSettingsStore.cs
- BamlTreeNode.cs
- WindowsProgressbar.cs
- path.cs
- RadioButton.cs
- SHA256CryptoServiceProvider.cs
- ConnectionPoint.cs
- NavigatingCancelEventArgs.cs
- UserControl.cs
- Win32KeyboardDevice.cs
- TextBreakpoint.cs
- ExecutionEngineException.cs
- SymLanguageVendor.cs
- DesignConnectionCollection.cs
- WmlPhoneCallAdapter.cs
- Int64AnimationBase.cs
- GenericAuthenticationEventArgs.cs
- EventRouteFactory.cs
- SecurityImpersonationBehavior.cs
- MergeLocalizationDirectives.cs
- ObjectDataProvider.cs
- UIElement3D.cs
- BmpBitmapEncoder.cs
- ClientScriptManager.cs
- DbProviderConfigurationHandler.cs
- DataGridTable.cs
- SecurityPolicySection.cs
- ToolBar.cs
- SqlInfoMessageEvent.cs
- DbParameterCollection.cs
- TypeTypeConverter.cs
- ColumnMapProcessor.cs
- Matrix3D.cs
- CharacterMetricsDictionary.cs
- BaseValidator.cs
- SimpleWorkerRequest.cs
- PropertyKey.cs