Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / Configuration / TimeoutValidationAttribute.cs / 1 / TimeoutValidationAttribute.cs
namespace System.Net { using System; using System.Configuration; using System.ComponentModel; // NOTE [[....]]: The old validation attribute was removed from System.ll and is // replaced by more flexible and robust validation/conversion design. // The change bellow is a simple fix to make things work with the least possible change ( it is an integration break ) // However, we already have a built-in support for configuration properties that store // Type names. We do reccomend that all uses of the validator bellow are converted to // properties of type Type ( instead of string ) which use the TypeNameConverter from System.Configuration.dll // Feel free to ask me for more details if you decide to do the conversion internal sealed class TimeoutValidator : ConfigurationValidatorBase { bool _zeroValid = false; internal TimeoutValidator(bool zeroValid) { _zeroValid = zeroValid; } public override bool CanValidate( Type type ) { return ( type == typeof( int ) || type == typeof( long ) ); } public override void Validate( object value ) { if (value == null) return; int timeout = (int)value; if (_zeroValid && timeout == 0) return; if (timeout <= 0 && timeout != System.Threading.Timeout.Infinite) { // Note [[....]] : This is a lab integration fix. Old code did not have any error message at this point // This code change accomplishes the same result. However its highly reccomended that a specific error message is givven // to the user so they know what exaclty is the problem ( i.e. the value must be a positive integer or be Infinite ) // To accomplish this - an exception with the specific error message could be thrown ( ArgumentException is prefferred ) throw new ConfigurationErrorsException(SR.GetString(SR.net_io_timeout_use_gt_zero)); } } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EdmPropertyAttribute.cs
- ListItemConverter.cs
- TextParagraphCache.cs
- Action.cs
- ILGenerator.cs
- CryptoConfig.cs
- UDPClient.cs
- SqlConnectionFactory.cs
- InternalPermissions.cs
- mongolianshape.cs
- ContainerActivationHelper.cs
- CannotUnloadAppDomainException.cs
- OracleCommand.cs
- NameValueCollection.cs
- ValueHandle.cs
- ProxyGenerationError.cs
- AccessDataSourceView.cs
- GroupBox.cs
- ObjectResult.cs
- IndexedGlyphRun.cs
- FormsAuthenticationUser.cs
- CodeDomSerializer.cs
- IssuanceLicense.cs
- HwndSubclass.cs
- DefaultEventAttribute.cs
- BufferedResponseStream.cs
- EdmValidator.cs
- ImmComposition.cs
- AssemblyNameUtility.cs
- RSAPKCS1KeyExchangeFormatter.cs
- Atom10FormatterFactory.cs
- Control.cs
- SqlUDTStorage.cs
- DataGridViewAutoSizeModeEventArgs.cs
- EmptyControlCollection.cs
- Journaling.cs
- IItemProperties.cs
- BitStream.cs
- UserUseLicenseDictionaryLoader.cs
- DataGridrowEditEndingEventArgs.cs
- TimeSpanSecondsConverter.cs
- ExpandSegment.cs
- MachineKeyValidationConverter.cs
- XPathArrayIterator.cs
- RectangleHotSpot.cs
- DoubleCollection.cs
- HashJoinQueryOperatorEnumerator.cs
- CounterCreationDataCollection.cs
- BrowserDefinitionCollection.cs
- WbemProvider.cs
- DataGridParentRows.cs
- ComponentChangingEvent.cs
- AggregateException.cs
- CompressionTracing.cs
- securitymgrsite.cs
- WindowsListViewItemStartMenu.cs
- TrustManagerMoreInformation.cs
- NamedElement.cs
- sqlcontext.cs
- EntityContainerAssociationSet.cs
- Int64KeyFrameCollection.cs
- MinimizableAttributeTypeConverter.cs
- VectorValueSerializer.cs
- SchemaImporterExtensionElement.cs
- FixedDSBuilder.cs
- DesignerAttribute.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- UnmanagedMemoryStream.cs
- OleDbWrapper.cs
- WindowsNonControl.cs
- XsltOutput.cs
- Tokenizer.cs
- BasicSecurityProfileVersion.cs
- PngBitmapEncoder.cs
- OdbcConnectionHandle.cs
- ProfessionalColorTable.cs
- DbDataReader.cs
- SemaphoreSecurity.cs
- WorkflowFileItem.cs
- ConditionalBranch.cs
- ClassGenerator.cs
- WpfGeneratedKnownProperties.cs
- SatelliteContractVersionAttribute.cs
- SoapExtensionStream.cs
- HtmlShimManager.cs
- CodeIterationStatement.cs
- IFlowDocumentViewer.cs
- _TLSstream.cs
- FileDialog.cs
- HtmlDocument.cs
- LongTypeConverter.cs
- PictureBox.cs
- MaterializeFromAtom.cs
- FixedSOMElement.cs
- _TransmitFileOverlappedAsyncResult.cs
- HttpWebRequest.cs
- ErrorFormatterPage.cs
- SqlParameterizer.cs
- CompressionTransform.cs
- SqlRecordBuffer.cs