Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Configuration / System / Configuration / InfiniteIntConverter.cs / 1 / InfiniteIntConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.IO; using System.Reflection; using System.Security.Permissions; using System.Xml; using System.Collections.Specialized; using System.Globalization; using System.ComponentModel; using System.Security; using System.Text; namespace System.Configuration { public sealed class InfiniteIntConverter : ConfigurationConverterBase { public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) { ValidateType(value, typeof(int)); if ((int)value == int.MaxValue) { return "Infinite"; } else { return ((int)value).ToString(CultureInfo.InvariantCulture); } } public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) { Debug.Assert(data is string, "data is string"); if ((string)data == "Infinite") { return int.MaxValue; } else { return Convert.ToInt32((string)data, 10); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Collections; using System.IO; using System.Reflection; using System.Security.Permissions; using System.Xml; using System.Collections.Specialized; using System.Globalization; using System.ComponentModel; using System.Security; using System.Text; namespace System.Configuration { public sealed class InfiniteIntConverter : ConfigurationConverterBase { public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) { ValidateType(value, typeof(int)); if ((int)value == int.MaxValue) { return "Infinite"; } else { return ((int)value).ToString(CultureInfo.InvariantCulture); } } public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) { Debug.Assert(data is string, "data is string"); if ((string)data == "Infinite") { return int.MaxValue; } else { return Convert.ToInt32((string)data, 10); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DocumentsTrace.cs
- ServerType.cs
- QilUnary.cs
- TypeFieldSchema.cs
- XmlHelper.cs
- TCPClient.cs
- FormViewDeletedEventArgs.cs
- DragEventArgs.cs
- RoutingEndpointTrait.cs
- ToolZone.cs
- DateTimeHelper.cs
- Timer.cs
- PropertyInfoSet.cs
- StreamingContext.cs
- RIPEMD160Managed.cs
- AssertUtility.cs
- SqlGenerator.cs
- HttpCacheParams.cs
- CodeChecksumPragma.cs
- UInt16Converter.cs
- List.cs
- DoubleAnimationUsingPath.cs
- ListenerElementsCollection.cs
- UrlPath.cs
- BindingElementExtensionElement.cs
- AssemblyBuilder.cs
- FastEncoderWindow.cs
- StringDictionaryCodeDomSerializer.cs
- _CookieModule.cs
- SqlUserDefinedAggregateAttribute.cs
- ClientBuildManager.cs
- RuntimeCompatibilityAttribute.cs
- ConfigXmlComment.cs
- TreeViewImageIndexConverter.cs
- SQLResource.cs
- CompilationUnit.cs
- Token.cs
- KnownTypesProvider.cs
- COM2ComponentEditor.cs
- EventLogConfiguration.cs
- TextEffectCollection.cs
- NotificationContext.cs
- ToolStripPanelRenderEventArgs.cs
- ThreadStartException.cs
- PKCS1MaskGenerationMethod.cs
- MSAAWinEventWrap.cs
- DynamicResourceExtension.cs
- CompilerGlobalScopeAttribute.cs
- ComponentFactoryHelpers.cs
- EventLogEntry.cs
- Popup.cs
- PaginationProgressEventArgs.cs
- Profiler.cs
- StringValueSerializer.cs
- UserControlParser.cs
- ZipFileInfoCollection.cs
- _CacheStreams.cs
- StreamHelper.cs
- Timer.cs
- PropertyMapper.cs
- ReachSerializationCacheItems.cs
- messageonlyhwndwrapper.cs
- WebPartMenu.cs
- XmlCharCheckingReader.cs
- WpfSharedXamlSchemaContext.cs
- HelpEvent.cs
- AdornerDecorator.cs
- TextDecorations.cs
- UIElementParaClient.cs
- ExtendedProperty.cs
- SynchronizedInputPattern.cs
- JapaneseCalendar.cs
- DbConnectionPoolIdentity.cs
- SimpleModelProvider.cs
- ColumnReorderedEventArgs.cs
- AnnotationStore.cs
- EntityModelSchemaGenerator.cs
- RsaKeyGen.cs
- SourceElementsCollection.cs
- OleDbFactory.cs
- StopStoryboard.cs
- ActivityCodeDomReferenceService.cs
- DateTimeConstantAttribute.cs
- DataGridViewUtilities.cs
- MobileResource.cs
- PEFileEvidenceFactory.cs
- SecurityManager.cs
- SafeTimerHandle.cs
- XmlSequenceWriter.cs
- IndentedWriter.cs
- QueryRewriter.cs
- ProviderUtil.cs
- TextPointer.cs
- WindowsFormsSectionHandler.cs
- SHA256.cs
- Content.cs
- CodeBlockBuilder.cs
- BindUriHelper.cs
- WindowsSpinner.cs
- ConnectionsZoneDesigner.cs