Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / System.Runtime.DurableInstancing / System / Runtime / TimeSpanOrInfiniteConverter.cs / 1305376 / TimeSpanOrInfiniteConverter.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Runtime { using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.ComponentModel; [SuppressMessage(FxCop.Category.Xaml, FxCop.Rule.TypeConvertersMustBePublic, Justification = "Only used by discovery, which doesn't support PT")] class TimeSpanOrInfiniteConverter : TimeSpanConverter { public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cultureInfo, object value, Type type) { if (value == null) { throw Fx.Exception.ArgumentNull("value"); } if (!(value is TimeSpan)) { throw Fx.Exception.Argument("value", SRCore.IncompatibleArgumentType(typeof(TimeSpan), value.GetType())); } if ((TimeSpan)value == TimeSpan.MaxValue) { return "Infinite"; } else { return base.ConvertTo(context, cultureInfo, value, type); } } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo cultureInfo, object data) { if (string.Equals((string)data, "infinite", StringComparison.OrdinalIgnoreCase)) { return TimeSpan.MaxValue; } else { return base.ConvertFrom(context, cultureInfo, data); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Runtime { using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.ComponentModel; [SuppressMessage(FxCop.Category.Xaml, FxCop.Rule.TypeConvertersMustBePublic, Justification = "Only used by discovery, which doesn't support PT")] class TimeSpanOrInfiniteConverter : TimeSpanConverter { public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cultureInfo, object value, Type type) { if (value == null) { throw Fx.Exception.ArgumentNull("value"); } if (!(value is TimeSpan)) { throw Fx.Exception.Argument("value", SRCore.IncompatibleArgumentType(typeof(TimeSpan), value.GetType())); } if ((TimeSpan)value == TimeSpan.MaxValue) { return "Infinite"; } else { return base.ConvertTo(context, cultureInfo, value, type); } } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo cultureInfo, object data) { if (string.Equals((string)data, "infinite", StringComparison.OrdinalIgnoreCase)) { return TimeSpan.MaxValue; } else { return base.ConvertFrom(context, cultureInfo, 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
- BoundField.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- IntSecurity.cs
- DeclarationUpdate.cs
- OutputCacheSettingsSection.cs
- TextCompositionManager.cs
- IdentityReference.cs
- DocumentEventArgs.cs
- ComPlusTraceRecord.cs
- FormatterConverter.cs
- EventListenerClientSide.cs
- PackageDigitalSignatureManager.cs
- Monitor.cs
- HttpModuleCollection.cs
- EntityClassGenerator.cs
- PtsCache.cs
- MsmqMessageProperty.cs
- SoapServerMessage.cs
- HasCopySemanticsAttribute.cs
- _NativeSSPI.cs
- DropDownButton.cs
- GetReadStreamResult.cs
- PaperSource.cs
- UnsafeNativeMethods.cs
- SubMenuStyleCollection.cs
- PackagePartCollection.cs
- FileStream.cs
- AttributeProviderAttribute.cs
- AsymmetricSignatureDeformatter.cs
- DataGridPagerStyle.cs
- Attribute.cs
- DifferencingCollection.cs
- DeferredTextReference.cs
- FileLevelControlBuilderAttribute.cs
- OnOperation.cs
- OrthographicCamera.cs
- PriorityQueue.cs
- SecurityDocument.cs
- CredentialCache.cs
- SiteMapSection.cs
- ConfigurationManager.cs
- NextPreviousPagerField.cs
- URIFormatException.cs
- Dispatcher.cs
- AppDomainUnloadedException.cs
- Timer.cs
- _NTAuthentication.cs
- KeyMatchBuilder.cs
- NumericUpDownAccelerationCollection.cs
- Vector3DCollection.cs
- DtdParser.cs
- HttpFileCollection.cs
- WorkflowMarkupSerializationManager.cs
- WebServiceData.cs
- DecimalAnimationBase.cs
- EarlyBoundInfo.cs
- Thread.cs
- Pointer.cs
- SendActivityDesignerTheme.cs
- _CacheStreams.cs
- PartitionerQueryOperator.cs
- TimelineGroup.cs
- CommonRemoteMemoryBlock.cs
- AuthorizationBehavior.cs
- RowUpdatedEventArgs.cs
- arclist.cs
- HtmlTitle.cs
- EncodingInfo.cs
- printdlgexmarshaler.cs
- MultiPropertyDescriptorGridEntry.cs
- PageCatalogPartDesigner.cs
- HtmlInputSubmit.cs
- ExpressionBuilder.cs
- StylusPointPropertyId.cs
- DecimalStorage.cs
- RelatedCurrencyManager.cs
- Help.cs
- WebConfigManager.cs
- RegisteredHiddenField.cs
- DrawingContextDrawingContextWalker.cs
- ReflectionUtil.cs
- CodeDirectiveCollection.cs
- DataSetUtil.cs
- SspiNegotiationTokenProvider.cs
- WindowAutomationPeer.cs
- XmlWellformedWriter.cs
- XmlChildEnumerator.cs
- Size3DConverter.cs
- RoutedPropertyChangedEventArgs.cs
- DispatcherTimer.cs
- OdbcError.cs
- HijriCalendar.cs
- DataTransferEventArgs.cs
- WebHttpElement.cs
- ServiceControllerDesigner.cs
- SQLConvert.cs
- SID.cs
- InstallerTypeAttribute.cs
- Double.cs
- TraceHwndHost.cs