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
![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
- XomlSerializationHelpers.cs
- SoapAttributeOverrides.cs
- ProcessHostServerConfig.cs
- Vector3DIndependentAnimationStorage.cs
- HWStack.cs
- WeakEventManager.cs
- TextStore.cs
- HtmlShim.cs
- LogManagementAsyncResult.cs
- LiteralDesigner.cs
- PersonalizablePropertyEntry.cs
- RefExpr.cs
- StandardCommands.cs
- SubstitutionList.cs
- WebServiceReceive.cs
- DataBindingCollectionConverter.cs
- ProtectedUri.cs
- LockRecursionException.cs
- LambdaCompiler.Unary.cs
- SingleStorage.cs
- DataGridViewCellMouseEventArgs.cs
- BidPrivateBase.cs
- ToggleProviderWrapper.cs
- MailMessageEventArgs.cs
- ConfigurationLockCollection.cs
- Activation.cs
- Label.cs
- InstanceDataCollection.cs
- ProviderCommandInfoUtils.cs
- PtsContext.cs
- ProfileService.cs
- ComplusEndpointConfigContainer.cs
- SmtpCommands.cs
- EntityDataSourceView.cs
- ContextQuery.cs
- DPTypeDescriptorContext.cs
- XmlAttributeCache.cs
- ContentDisposition.cs
- DataGridViewRowHeaderCell.cs
- SchemaTableColumn.cs
- ParserStack.cs
- ParseNumbers.cs
- BulletedList.cs
- KeyValuePair.cs
- Math.cs
- ComAdminWrapper.cs
- WindowsGraphics.cs
- ConfigurationManagerHelper.cs
- SystemResources.cs
- PathGradientBrush.cs
- DynamicRenderer.cs
- PageThemeBuildProvider.cs
- DataBoundControl.cs
- BaseTemplateBuildProvider.cs
- TableRow.cs
- ItemContainerProviderWrapper.cs
- Vector3DConverter.cs
- FormDesigner.cs
- PreDigestedSignedInfo.cs
- EntityStoreSchemaFilterEntry.cs
- RepeaterItemCollection.cs
- CryptoApi.cs
- DataTemplate.cs
- StructuredProperty.cs
- UpdatePanelControlTrigger.cs
- NumericUpDown.cs
- ResourceContainer.cs
- GridErrorDlg.cs
- CredentialCache.cs
- EditingCommands.cs
- ObjectItemConventionAssemblyLoader.cs
- LineBreak.cs
- MatrixValueSerializer.cs
- DataGridViewDataConnection.cs
- QueryPageSettingsEventArgs.cs
- SemanticBasicElement.cs
- CssTextWriter.cs
- WebPermission.cs
- TableDetailsRow.cs
- GlyphRunDrawing.cs
- DataGridPagerStyle.cs
- HashCryptoHandle.cs
- MenuBindingsEditor.cs
- LeaseManager.cs
- CompatibleComparer.cs
- C14NUtil.cs
- OverrideMode.cs
- QilLiteral.cs
- KeySpline.cs
- DataBinder.cs
- DataRelation.cs
- WindowsClientCredential.cs
- SortedDictionary.cs
- WebBrowsableAttribute.cs
- DataGridViewCellCancelEventArgs.cs
- ItemMap.cs
- XPathNavigator.cs
- SafeMILHandleMemoryPressure.cs
- ChoiceConverter.cs
- OrCondition.cs