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
- DictionaryContent.cs
- Int32CollectionConverter.cs
- HttpFileCollectionBase.cs
- PseudoWebRequest.cs
- ExclusiveTcpListener.cs
- ListParaClient.cs
- TabItem.cs
- BasicBrowserDialog.designer.cs
- FlowDocument.cs
- QilStrConcatenator.cs
- InOutArgument.cs
- httpapplicationstate.cs
- QueueProcessor.cs
- MetadataSerializer.cs
- sapiproxy.cs
- SmiMetaData.cs
- BinaryCommonClasses.cs
- BaseTemplateCodeDomTreeGenerator.cs
- TracePayload.cs
- DataColumn.cs
- QueryOutputWriter.cs
- SqlUtil.cs
- CodeCastExpression.cs
- DependencyObjectProvider.cs
- SplitterCancelEvent.cs
- SqlCachedBuffer.cs
- Misc.cs
- HostingEnvironmentException.cs
- TypeUtil.cs
- Path.cs
- EditorAttribute.cs
- ManagementQuery.cs
- FileDialog.cs
- DummyDataSource.cs
- AppSettingsReader.cs
- DispatcherHooks.cs
- IssuedTokenClientElement.cs
- SchemaAttDef.cs
- FormDesigner.cs
- CapacityStreamGeometryContext.cs
- Transform3DCollection.cs
- DecodeHelper.cs
- ConfigurationManagerHelperFactory.cs
- TypeConverterHelper.cs
- UserInitiatedRoutedEventPermission.cs
- PrintControllerWithStatusDialog.cs
- TextMarkerSource.cs
- HtmlFormParameterReader.cs
- SerialReceived.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- PathParser.cs
- ScrollChangedEventArgs.cs
- ParagraphVisual.cs
- AuthorizationRule.cs
- PickBranch.cs
- ClientSettingsProvider.cs
- Closure.cs
- WebBrowserSiteBase.cs
- ListControl.cs
- OpenFileDialog.cs
- Registry.cs
- FusionWrap.cs
- HtmlWindowCollection.cs
- RemoteWebConfigurationHost.cs
- WebPartConnection.cs
- Update.cs
- PathFigureCollection.cs
- SerializableAttribute.cs
- RijndaelManaged.cs
- RuleSetCollection.cs
- CountdownEvent.cs
- CheckBoxList.cs
- IODescriptionAttribute.cs
- XmlMembersMapping.cs
- ItemAutomationPeer.cs
- ChildChangedEventArgs.cs
- ComplexObject.cs
- AnimationClockResource.cs
- BmpBitmapDecoder.cs
- ContentTypeSettingClientMessageFormatter.cs
- MissingManifestResourceException.cs
- PreservationFileWriter.cs
- MessageContractExporter.cs
- PageRouteHandler.cs
- ProcessHostServerConfig.cs
- DecimalAnimation.cs
- PolicyLevel.cs
- WebPartUtil.cs
- CodeDomSerializerException.cs
- ComponentGuaranteesAttribute.cs
- ManifestSignatureInformation.cs
- FindCompletedEventArgs.cs
- SqlTrackingWorkflowInstance.cs
- SrgsDocumentParser.cs
- Size.cs
- HttpRequestTraceRecord.cs
- ObjectDataSourceDisposingEventArgs.cs
- _Semaphore.cs
- DataObjectMethodAttribute.cs
- DataError.cs