Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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)); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. 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)); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlSchemaCollection.cs
- TcpConnectionPool.cs
- SimpleBitVector32.cs
- MessageAction.cs
- DataControlFieldCollection.cs
- MemberCollection.cs
- CheckBoxField.cs
- DbProviderManifest.cs
- ElementInit.cs
- GenericQueueSurrogate.cs
- EntityViewGenerationConstants.cs
- ServiceModelConfigurationElementCollection.cs
- IntPtr.cs
- ToolBarButtonDesigner.cs
- dtdvalidator.cs
- ValidationRuleCollection.cs
- SessionIDManager.cs
- RequestSecurityTokenForRemoteTokenFactory.cs
- XmlnsDefinitionAttribute.cs
- SafeSecurityHandles.cs
- Propagator.Evaluator.cs
- OdbcConnection.cs
- CultureMapper.cs
- OleAutBinder.cs
- InkCanvasSelection.cs
- DataGridViewTopLeftHeaderCell.cs
- UnauthorizedAccessException.cs
- PackWebResponse.cs
- Number.cs
- PersistenceTypeAttribute.cs
- SQLDoubleStorage.cs
- ComponentTray.cs
- PropertyNames.cs
- SamlConstants.cs
- DefaultAsyncDataDispatcher.cs
- DocumentAutomationPeer.cs
- XamlDesignerSerializationManager.cs
- sqlstateclientmanager.cs
- X509CertificateCollection.cs
- MappingSource.cs
- _IPv4Address.cs
- XmlToDatasetMap.cs
- DefaultEventAttribute.cs
- HierarchicalDataTemplate.cs
- ComNativeDescriptor.cs
- SettingsAttributes.cs
- HttpSysSettings.cs
- Console.cs
- DataGridPreparingCellForEditEventArgs.cs
- EndCreateSecurityTokenRequest.cs
- ReversePositionQuery.cs
- RoutedPropertyChangedEventArgs.cs
- DataSourceHelper.cs
- PhysicalFontFamily.cs
- ComponentResourceManager.cs
- XmlSchemaImport.cs
- ValidationErrorEventArgs.cs
- CustomValidator.cs
- DetailsViewDeletedEventArgs.cs
- InheritedPropertyChangedEventArgs.cs
- JoinTreeNode.cs
- HealthMonitoringSection.cs
- DBDataPermission.cs
- ListArgumentProvider.cs
- WebCategoryAttribute.cs
- NamespaceCollection.cs
- SafeRightsManagementHandle.cs
- TargetControlTypeCache.cs
- WaveHeader.cs
- CompilerGlobalScopeAttribute.cs
- TraceUtils.cs
- TransportContext.cs
- NativeRightsManagementAPIsStructures.cs
- SerializationEventsCache.cs
- DataGridViewRowEventArgs.cs
- OneToOneMappingSerializer.cs
- CompiledELinqQueryState.cs
- WindowsTokenRoleProvider.cs
- Int32RectValueSerializer.cs
- ValueChangedEventManager.cs
- ProfileBuildProvider.cs
- CompoundFileIOPermission.cs
- SerializationSectionGroup.cs
- BreakSafeBase.cs
- BamlRecords.cs
- EncoderBestFitFallback.cs
- FixedSOMLineRanges.cs
- Policy.cs
- DictionarySectionHandler.cs
- UserControlBuildProvider.cs
- ResXFileRef.cs
- Convert.cs
- FormsAuthenticationUser.cs
- InvokeHandlers.cs
- Properties.cs
- XmlSchemaSimpleContentRestriction.cs
- ResponseBodyWriter.cs
- BuildProviderAppliesToAttribute.cs
- Border.cs
- XmlILTrace.cs