Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / TimeSpanSecondsOrInfiniteConverter.cs / 1305376 / TimeSpanSecondsOrInfiniteConverter.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 TimeSpanSecondsOrInfiniteConverter : TimeSpanSecondsConverter { public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) { ValidateType(value, typeof(TimeSpan)); if ((TimeSpan)value == TimeSpan.MaxValue) { return "Infinite"; } else { return base.ConvertTo(ctx, ci, value, type); } } public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) { Debug.Assert(data is string, "data is string"); if ((string)data == "Infinite") { return TimeSpan.MaxValue; } else { return base.ConvertFrom(ctx, ci, data); } } } } // 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 TimeSpanSecondsOrInfiniteConverter : TimeSpanSecondsConverter { public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) { ValidateType(value, typeof(TimeSpan)); if ((TimeSpan)value == TimeSpan.MaxValue) { return "Infinite"; } else { return base.ConvertTo(ctx, ci, value, type); } } public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) { Debug.Assert(data is string, "data is string"); if ((string)data == "Infinite") { return TimeSpan.MaxValue; } else { return base.ConvertFrom(ctx, ci, data); } } } } // 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
- PictureBoxDesigner.cs
- SqlGenericUtil.cs
- PingReply.cs
- OutputCacheProfile.cs
- IdnElement.cs
- HandleCollector.cs
- DesignerUtils.cs
- TypefaceCollection.cs
- TableItemProviderWrapper.cs
- recordstatefactory.cs
- SimpleApplicationHost.cs
- XmlChoiceIdentifierAttribute.cs
- ApplyImportsAction.cs
- X509Utils.cs
- QueryAsyncResult.cs
- GrammarBuilderPhrase.cs
- StoreItemCollection.Loader.cs
- Cursors.cs
- ColumnHeaderCollectionEditor.cs
- TextPointerBase.cs
- GridViewRowPresenterBase.cs
- CodeNamespaceImport.cs
- AssemblyBuilder.cs
- HttpPostedFileWrapper.cs
- SolidBrush.cs
- ModelEditingScope.cs
- NotifyParentPropertyAttribute.cs
- FixedSOMFixedBlock.cs
- DllNotFoundException.cs
- CharEntityEncoderFallback.cs
- ResourcesBuildProvider.cs
- WebPartActionVerb.cs
- PropertyInfoSet.cs
- StyleXamlTreeBuilder.cs
- GPRECT.cs
- EntityTypeBase.cs
- Quad.cs
- ApplicationInterop.cs
- EmissiveMaterial.cs
- TextReader.cs
- IndentedWriter.cs
- XamlLoadErrorInfo.cs
- ButtonFieldBase.cs
- Shared.cs
- CompressEmulationStream.cs
- DateTimeParse.cs
- SqlSupersetValidator.cs
- ErrorTableItemStyle.cs
- GeometryConverter.cs
- X509PeerCertificateAuthenticationElement.cs
- followingsibling.cs
- BitmapEncoder.cs
- RegexGroupCollection.cs
- MultipleViewPatternIdentifiers.cs
- PersonalizationStateQuery.cs
- MethodRental.cs
- XmlNodeReader.cs
- LinkDescriptor.cs
- DbCommandDefinition.cs
- SortedList.cs
- ExtenderProvidedPropertyAttribute.cs
- DataGridTableCollection.cs
- _BufferOffsetSize.cs
- DiscoveryService.cs
- CancellationHandlerDesigner.cs
- ImmutablePropertyDescriptorGridEntry.cs
- SignedPkcs7.cs
- ObjectDataProvider.cs
- RIPEMD160.cs
- PtsCache.cs
- TrackingServices.cs
- PointCollection.cs
- WorkflowCreationContext.cs
- HitTestWithGeometryDrawingContextWalker.cs
- FloaterParagraph.cs
- SiteMapNodeItem.cs
- NullRuntimeConfig.cs
- OverflowException.cs
- TreeViewEvent.cs
- VerificationException.cs
- MULTI_QI.cs
- XmlLanguageConverter.cs
- SqlServer2KCompatibilityAnnotation.cs
- CustomCategoryAttribute.cs
- WebPartDisplayModeCollection.cs
- FocusManager.cs
- Pkcs7Signer.cs
- DesigntimeLicenseContextSerializer.cs
- RoutedUICommand.cs
- BrowserInteropHelper.cs
- IPGlobalProperties.cs
- InputQueueChannel.cs
- ValuePattern.cs
- FormViewPageEventArgs.cs
- DllNotFoundException.cs
- Point4DValueSerializer.cs
- SrgsSemanticInterpretationTag.cs
- TransformValueSerializer.cs
- XamlBuildProvider.cs
- CorrelationActionMessageFilter.cs