Code:
/ FX-1434 / FX-1434 / 1.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
- TableCell.cs
- Message.cs
- FieldDescriptor.cs
- CanonicalXml.cs
- WriteTimeStream.cs
- NameSpaceExtractor.cs
- AnnotationService.cs
- SafeCertificateContext.cs
- ViewCellRelation.cs
- MgmtConfigurationRecord.cs
- ItemCollectionEditor.cs
- _SafeNetHandles.cs
- FtpWebRequest.cs
- ViewSimplifier.cs
- ManagedIStream.cs
- VisualStyleTypesAndProperties.cs
- ResourcePool.cs
- ThemeableAttribute.cs
- EntityViewGenerator.cs
- GlobalProxySelection.cs
- BulletChrome.cs
- AssemblyInfo.cs
- BigInt.cs
- WebPartHeaderCloseVerb.cs
- FilterableAttribute.cs
- BindableTemplateBuilder.cs
- EndEvent.cs
- PropertyGroupDescription.cs
- SortableBindingList.cs
- XamlSerializer.cs
- AutomationIdentifierGuids.cs
- BrowserCapabilitiesFactoryBase.cs
- InvalidOperationException.cs
- WorkflowDesigner.cs
- BinHexDecoder.cs
- HtmlTableRow.cs
- OptimalBreakSession.cs
- XmlAttributeCache.cs
- RenderingEventArgs.cs
- WebControl.cs
- HttpHandlerAction.cs
- CallbackHandler.cs
- EventProviderBase.cs
- CodeTypeReferenceExpression.cs
- HtmlInputPassword.cs
- ManagementOptions.cs
- ResXDataNode.cs
- TdsValueSetter.cs
- SubclassTypeValidatorAttribute.cs
- NonSerializedAttribute.cs
- SchemaImporterExtension.cs
- WebPartCatalogAddVerb.cs
- IsolatedStorageFileStream.cs
- ObjectDataSourceDisposingEventArgs.cs
- NotSupportedException.cs
- DataGridViewColumnTypePicker.cs
- ContextMenuStrip.cs
- SafeRegistryHandle.cs
- FileUtil.cs
- DefaultShape.cs
- DATA_BLOB.cs
- sqlcontext.cs
- DispatchWrapper.cs
- ValidatorUtils.cs
- PermissionSetEnumerator.cs
- CheckedListBox.cs
- ErrorView.xaml.cs
- InitializationEventAttribute.cs
- SoapFormatterSinks.cs
- TextRangeSerialization.cs
- ProviderMetadata.cs
- MatrixTransform.cs
- Condition.cs
- DbBuffer.cs
- Transform.cs
- EditingScope.cs
- PromptStyle.cs
- FileDetails.cs
- SafeRsaProviderHandle.cs
- RoutedPropertyChangedEventArgs.cs
- DBCSCodePageEncoding.cs
- Version.cs
- FactoryGenerator.cs
- Policy.cs
- AutoGeneratedFieldProperties.cs
- DataServiceProcessingPipeline.cs
- DynamicResourceExtension.cs
- TreeViewCancelEvent.cs
- StylusPointPropertyInfo.cs
- ClientViaElement.cs
- Internal.cs
- FixedSOMTableRow.cs
- LockedAssemblyCache.cs
- QilVisitor.cs
- PerformanceCounterPermissionEntryCollection.cs
- FormatSettings.cs
- EntityDataSourceContainerNameConverter.cs
- NamespaceEmitter.cs
- XmlComplianceUtil.cs
- WSFederationHttpSecurityElement.cs