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
- Int64.cs
- Exceptions.cs
- ObjectComplexPropertyMapping.cs
- ManagedIStream.cs
- InputEventArgs.cs
- GridItem.cs
- SamlDoNotCacheCondition.cs
- CustomCredentialPolicy.cs
- WebResponse.cs
- SrgsElement.cs
- PointConverter.cs
- FaultConverter.cs
- NodeLabelEditEvent.cs
- TableLayoutSettings.cs
- HtmlInputImage.cs
- HexParser.cs
- NavigationHelper.cs
- XamlGridLengthSerializer.cs
- FolderBrowserDialog.cs
- AnnotationStore.cs
- ResourceReferenceExpressionConverter.cs
- AlignmentYValidation.cs
- TemplateApplicationHelper.cs
- Triangle.cs
- LinkUtilities.cs
- Environment.cs
- ValidatorCompatibilityHelper.cs
- Pair.cs
- AxisAngleRotation3D.cs
- InputLangChangeEvent.cs
- DSASignatureDeformatter.cs
- TdsValueSetter.cs
- TypographyProperties.cs
- ServicePoint.cs
- MobileControlPersister.cs
- UiaCoreTypesApi.cs
- X509SecurityTokenProvider.cs
- GeneralTransform3D.cs
- FrameworkPropertyMetadata.cs
- MILUtilities.cs
- CodeCatchClause.cs
- EventLogPermission.cs
- BoolExpression.cs
- AccessText.cs
- DelegatingHeader.cs
- BitStream.cs
- ScriptingWebServicesSectionGroup.cs
- InputLangChangeRequestEvent.cs
- DrawingCollection.cs
- InputBinding.cs
- Solver.cs
- WasHttpHandlersInstallComponent.cs
- ISCIIEncoding.cs
- ListBoxItem.cs
- ToolStripRendererSwitcher.cs
- EdmComplexPropertyAttribute.cs
- CompareValidator.cs
- MobileUserControlDesigner.cs
- __Filters.cs
- SafeFileHandle.cs
- FocusTracker.cs
- _LazyAsyncResult.cs
- ListView.cs
- BigInt.cs
- GregorianCalendar.cs
- TrackingLocationCollection.cs
- CompressStream.cs
- BitmapEffectInput.cs
- TextTreeExtractElementUndoUnit.cs
- Wildcard.cs
- ValueProviderWrapper.cs
- SafeEventLogWriteHandle.cs
- coordinatorscratchpad.cs
- _ListenerAsyncResult.cs
- SafeRightsManagementEnvironmentHandle.cs
- SortedSetDebugView.cs
- ConnectionManagementElementCollection.cs
- RSATokenProvider.cs
- SqlInternalConnection.cs
- ToolStripDesigner.cs
- DocumentApplication.cs
- XPathSelectionIterator.cs
- SymbolMethod.cs
- ResourceKey.cs
- ButtonStandardAdapter.cs
- HostVisual.cs
- CodeParameterDeclarationExpressionCollection.cs
- WebDisplayNameAttribute.cs
- EncryptedReference.cs
- WsatServiceAddress.cs
- TouchFrameEventArgs.cs
- WebPartAddingEventArgs.cs
- FilterQueryOptionExpression.cs
- ParseChildrenAsPropertiesAttribute.cs
- Journal.cs
- XmlArrayAttribute.cs
- Wildcard.cs
- Config.cs
- LockedActivityGlyph.cs
- UnsafeNetInfoNativeMethods.cs