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
- TraceInternal.cs
- SingleQueryOperator.cs
- DelegateHelpers.cs
- AssemblyHelper.cs
- ObjectPersistData.cs
- AppDomainProtocolHandler.cs
- ConfigViewGenerator.cs
- DataSourceCache.cs
- MSAAEventDispatcher.cs
- AddInServer.cs
- RawStylusActions.cs
- MenuItemStyleCollectionEditor.cs
- NetSectionGroup.cs
- XmlHierarchicalEnumerable.cs
- ChangePasswordDesigner.cs
- OverflowException.cs
- XmlAttributeCache.cs
- TreeIterator.cs
- XsltQilFactory.cs
- SiteIdentityPermission.cs
- DataReaderContainer.cs
- HyperLinkColumn.cs
- RulePatternOps.cs
- TypeSystemProvider.cs
- _NegoState.cs
- IdentityNotMappedException.cs
- DPCustomTypeDescriptor.cs
- ProgressBarRenderer.cs
- MainMenu.cs
- CssStyleCollection.cs
- Size3D.cs
- PerformanceCountersElement.cs
- FilterEventArgs.cs
- ComponentChangedEvent.cs
- _ListenerAsyncResult.cs
- TextViewBase.cs
- DeclaredTypeElement.cs
- SqlClientFactory.cs
- SecureEnvironment.cs
- ConfigurationPermission.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- ThreadNeutralSemaphore.cs
- InputProcessorProfilesLoader.cs
- NativeRightsManagementAPIsStructures.cs
- HtmlControlPersistable.cs
- HtmlShimManager.cs
- SQLMembershipProvider.cs
- AnnotationAdorner.cs
- SubMenuStyleCollection.cs
- ProviderException.cs
- WSSecurityOneDotOneReceiveSecurityHeader.cs
- BoolExpression.cs
- WindowInteropHelper.cs
- ResourceWriter.cs
- WindowsFormsEditorServiceHelper.cs
- TableLayoutRowStyleCollection.cs
- XamlContextStack.cs
- PageHandlerFactory.cs
- GridViewColumnHeaderAutomationPeer.cs
- ReadWriteSpinLock.cs
- IProvider.cs
- SettingsPropertyValue.cs
- FileLevelControlBuilderAttribute.cs
- ReadonlyMessageFilter.cs
- ObjectDataSource.cs
- RowType.cs
- SettingsBase.cs
- TransportConfigurationTypeElementCollection.cs
- ComplexLine.cs
- HotSpotCollection.cs
- ReliableSessionBindingElementImporter.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- XmlWriterSettings.cs
- GlyphTypeface.cs
- Listbox.cs
- PolicyLevel.cs
- StatusBar.cs
- HttpDebugHandler.cs
- ImageCodecInfoPrivate.cs
- PageAdapter.cs
- ProcessHostFactoryHelper.cs
- ThicknessAnimation.cs
- ManipulationBoundaryFeedbackEventArgs.cs
- MaskDesignerDialog.cs
- ColumnHeader.cs
- PersistChildrenAttribute.cs
- SqlBulkCopyColumnMappingCollection.cs
- TraceListener.cs
- PageThemeCodeDomTreeGenerator.cs
- BrowserCapabilitiesCodeGenerator.cs
- HtmlObjectListAdapter.cs
- PerspectiveCamera.cs
- ConfigXmlSignificantWhitespace.cs
- CompressedStack.cs
- WeakHashtable.cs
- DesignBindingValueUIHandler.cs
- SizeFConverter.cs
- TextFormatterHost.cs
- SafeNativeMethodsOther.cs
- SelectionRangeConverter.cs