Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XsdCachingReader.cs
- ReplacementText.cs
- CollectionAdapters.cs
- EndEvent.cs
- AddingNewEventArgs.cs
- RemoteWebConfigurationHostStream.cs
- Vars.cs
- AuthenticationService.cs
- ExtendedPropertyDescriptor.cs
- EpmAttributeNameBuilder.cs
- X509Extension.cs
- StrongName.cs
- MailHeaderInfo.cs
- RangeExpression.cs
- DataChangedEventManager.cs
- CodeDomComponentSerializationService.cs
- HttpSessionStateWrapper.cs
- UnmanagedMarshal.cs
- ServiceModelActivationSectionGroup.cs
- ModelService.cs
- StyleCollectionEditor.cs
- TakeOrSkipWhileQueryOperator.cs
- XmlSchemaObject.cs
- UnsafeNativeMethods.cs
- IPPacketInformation.cs
- XmlCharCheckingWriter.cs
- _ContextAwareResult.cs
- TypeDefinition.cs
- PackWebRequestFactory.cs
- tooltip.cs
- FileAuthorizationModule.cs
- InternalBufferOverflowException.cs
- NativeMethods.cs
- SimpleNameService.cs
- DropShadowBitmapEffect.cs
- OrderedHashRepartitionStream.cs
- LoadGrammarCompletedEventArgs.cs
- Int16Storage.cs
- HtmlWindow.cs
- LogicalChannel.cs
- SoapHeader.cs
- UndoUnit.cs
- PresentationTraceSources.cs
- SafeHandle.cs
- DesignerToolboxInfo.cs
- MultiDataTrigger.cs
- MailMessage.cs
- ECDsa.cs
- HierarchicalDataSourceControl.cs
- Pkcs9Attribute.cs
- DirectoryGroupQuery.cs
- ParameterCollectionEditorForm.cs
- ColumnMapTranslator.cs
- RegexInterpreter.cs
- DbConnectionClosed.cs
- ManagedFilter.cs
- MergeLocalizationDirectives.cs
- CorrelationTokenInvalidatedHandler.cs
- XmlDocumentFragment.cs
- DataGridViewRowPostPaintEventArgs.cs
- SettingsBindableAttribute.cs
- BuildResultCache.cs
- IPHostEntry.cs
- WrappedKeySecurityTokenParameters.cs
- SmtpFailedRecipientException.cs
- ManagementObjectSearcher.cs
- JapaneseLunisolarCalendar.cs
- Delegate.cs
- GregorianCalendar.cs
- CredentialCache.cs
- PointLight.cs
- ActivationServices.cs
- DataSourceListEditor.cs
- XmlUtf8RawTextWriter.cs
- AnnotationHelper.cs
- EventNotify.cs
- Help.cs
- HandleValueEditor.cs
- AuthenticationModuleElement.cs
- TypePresenter.xaml.cs
- WizardForm.cs
- SparseMemoryStream.cs
- TypeUtil.cs
- Context.cs
- HtmlProps.cs
- ReceiveActivityValidator.cs
- PolyQuadraticBezierSegment.cs
- CompareValidator.cs
- CodeTryCatchFinallyStatement.cs
- HighlightComponent.cs
- FormsAuthenticationUserCollection.cs
- ReadOnlyHierarchicalDataSourceView.cs
- PixelFormats.cs
- PointAnimationClockResource.cs
- InputLangChangeRequestEvent.cs
- DnsPermission.cs
- NTAccount.cs
- OpenFileDialog.cs
- FormattedTextSymbols.cs
- DataServiceRequestOfT.cs