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
- RoleServiceManager.cs
- ExpressionNode.cs
- DataListItemEventArgs.cs
- Hex.cs
- XmlElementAttribute.cs
- _ChunkParse.cs
- KnownAssembliesSet.cs
- SqlOuterApplyReducer.cs
- ReadOnlyPropertyMetadata.cs
- CodeNamespaceCollection.cs
- CellRelation.cs
- GiveFeedbackEventArgs.cs
- DataGridViewTextBoxCell.cs
- StylusCollection.cs
- Brushes.cs
- DataGridAddNewRow.cs
- DetailsViewPagerRow.cs
- StringCollection.cs
- Switch.cs
- TableDetailsRow.cs
- FontFamily.cs
- DataSysAttribute.cs
- MenuEventArgs.cs
- NullReferenceException.cs
- BinaryObjectReader.cs
- XPathNavigatorReader.cs
- TransportSecurityHelpers.cs
- PingOptions.cs
- SynchronizedInputHelper.cs
- AuthenticationService.cs
- ScalarConstant.cs
- InternalDispatchObject.cs
- XmlSchemaAnnotated.cs
- TextEvent.cs
- DoubleCollectionValueSerializer.cs
- ContentPlaceHolder.cs
- ActivityFunc.cs
- DateTimeEditor.cs
- VerticalConnector.xaml.cs
- SHA256.cs
- BitmapEffectRenderDataResource.cs
- HttpWrapper.cs
- TabletDevice.cs
- CollectionBuilder.cs
- CompilerErrorCollection.cs
- EntitySqlQueryCacheEntry.cs
- VideoDrawing.cs
- BrowsableAttribute.cs
- BitmapCacheBrush.cs
- SiteOfOriginPart.cs
- PrtCap_Reader.cs
- RemoteDebugger.cs
- TabControlAutomationPeer.cs
- input.cs
- DocComment.cs
- FormViewDeletedEventArgs.cs
- SecurityNegotiationException.cs
- SqlProvider.cs
- FrameworkTemplate.cs
- WebPartCancelEventArgs.cs
- CompilerParameters.cs
- XmlSchemaAnyAttribute.cs
- ping.cs
- PermissionRequestEvidence.cs
- EncoderReplacementFallback.cs
- _AutoWebProxyScriptWrapper.cs
- XmlEntityReference.cs
- GatewayDefinition.cs
- TargetConverter.cs
- XmlReflectionImporter.cs
- ReflectionPermission.cs
- DataListCommandEventArgs.cs
- TextRunProperties.cs
- mil_sdk_version.cs
- IProvider.cs
- PtsHost.cs
- DataGridViewCellParsingEventArgs.cs
- XamlClipboardData.cs
- WebConfigurationHost.cs
- MethodToken.cs
- listitem.cs
- XmlValueConverter.cs
- XmlQueryStaticData.cs
- EntityModelBuildProvider.cs
- StandardBindingElement.cs
- SEHException.cs
- DataGridState.cs
- UnsafeNativeMethods.cs
- LinkTarget.cs
- ShowExpandedMultiValueConverter.cs
- NetworkAddressChange.cs
- GenericTypeParameterBuilder.cs
- ObjectToModelValueConverter.cs
- ElementUtil.cs
- ISFClipboardData.cs
- OrderedDictionary.cs
- CompilationSection.cs
- SystemDiagnosticsSection.cs
- XmlAggregates.cs
- PrefixQName.cs