Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Configuration / TimeoutValidationAttribute.cs / 1305376 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DiscoveryOperationContext.cs
- QueryCacheKey.cs
- SyndicationContent.cs
- BaseDataBoundControl.cs
- IntranetCredentialPolicy.cs
- VSWCFServiceContractGenerator.cs
- securestring.cs
- ModelChangedEventArgsImpl.cs
- DataException.cs
- StatusBarItemAutomationPeer.cs
- BooleanExpr.cs
- XXXInfos.cs
- baseaxisquery.cs
- DbProviderFactory.cs
- ResourceDescriptionAttribute.cs
- HtmlTableCell.cs
- Normalization.cs
- EnterpriseServicesHelper.cs
- processwaithandle.cs
- CodeConstructor.cs
- Transactions.cs
- TabRenderer.cs
- SqlStream.cs
- MultiSelectRootGridEntry.cs
- ValidationUtility.cs
- ByteStreamMessageUtility.cs
- CleanUpVirtualizedItemEventArgs.cs
- InternalControlCollection.cs
- AutomationFocusChangedEventArgs.cs
- DocumentViewerHelper.cs
- UnaryExpression.cs
- _NegoStream.cs
- CodeParameterDeclarationExpressionCollection.cs
- TranslateTransform3D.cs
- DataColumn.cs
- DetailsViewRowCollection.cs
- ObjRef.cs
- TextParagraphCache.cs
- ScrollBar.cs
- UpdateManifestForBrowserApplication.cs
- CodeDefaultValueExpression.cs
- XmlObjectSerializerContext.cs
- DataColumnPropertyDescriptor.cs
- SoapProtocolReflector.cs
- TableParaClient.cs
- ScriptingRoleServiceSection.cs
- InvalidateEvent.cs
- XmlSerializerNamespaces.cs
- DecoderBestFitFallback.cs
- UInt32Converter.cs
- XmlILModule.cs
- AspNetCompatibilityRequirementsAttribute.cs
- ToolStripContainerDesigner.cs
- DocumentAutomationPeer.cs
- Attributes.cs
- sqlmetadatafactory.cs
- BamlLocalizer.cs
- CollectionConverter.cs
- AttachedPropertyBrowsableAttribute.cs
- ExpressionVisitor.cs
- InternalConfigHost.cs
- ProfileBuildProvider.cs
- ComPlusInstanceProvider.cs
- ProjectionRewriter.cs
- TemporaryBitmapFile.cs
- MethodBuilder.cs
- XmlDocumentType.cs
- SqlRecordBuffer.cs
- ChildDocumentBlock.cs
- TagPrefixInfo.cs
- MdImport.cs
- CompilerGeneratedAttribute.cs
- ConfigurationSectionGroup.cs
- XPathChildIterator.cs
- LinkLabel.cs
- SiteMap.cs
- TextRunCache.cs
- GlyphsSerializer.cs
- DateTimeFormatInfoScanner.cs
- Merger.cs
- CurrencyWrapper.cs
- ModuleConfigurationInfo.cs
- XomlCompiler.cs
- PageOrientation.cs
- CompositeFontParser.cs
- Font.cs
- EntityConnectionStringBuilder.cs
- SocketCache.cs
- ParallelActivityDesigner.cs
- StringAnimationUsingKeyFrames.cs
- Choices.cs
- PixelFormats.cs
- ColorAnimationBase.cs
- WindowsRichEdit.cs
- CryptographicAttribute.cs
- TimeoutValidationAttribute.cs
- AdPostCacheSubstitution.cs
- ByteRangeDownloader.cs
- DeclaredTypeValidator.cs
- DescendantOverDescendantQuery.cs