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
- HandoffBehavior.cs
- RemotingConfiguration.cs
- SoapFault.cs
- ProjectedSlot.cs
- CaseInsensitiveHashCodeProvider.cs
- sortedlist.cs
- OdbcConnectionOpen.cs
- DataDocumentXPathNavigator.cs
- DataColumn.cs
- ComponentResourceManager.cs
- WSSecurityPolicy.cs
- DataGridViewLinkCell.cs
- StylusCollection.cs
- AudioStateChangedEventArgs.cs
- COM2ComponentEditor.cs
- AdjustableArrowCap.cs
- CompiledQueryCacheKey.cs
- DataGridTable.cs
- VectorCollectionValueSerializer.cs
- RootDesignerSerializerAttribute.cs
- GroupedContextMenuStrip.cs
- DrawListViewColumnHeaderEventArgs.cs
- PropertyChangingEventArgs.cs
- CustomAssemblyResolver.cs
- AliasGenerator.cs
- ObfuscateAssemblyAttribute.cs
- DictionaryGlobals.cs
- AvtEvent.cs
- CellQuery.cs
- SSmlParser.cs
- GraphicsState.cs
- CellParagraph.cs
- UrlAuthorizationModule.cs
- VersionConverter.cs
- RemoveStoryboard.cs
- Int64.cs
- InheritanceAttribute.cs
- HttpTransportManager.cs
- ResourceManager.cs
- SoapInteropTypes.cs
- QueryGeneratorBase.cs
- DelegatingConfigHost.cs
- ContentType.cs
- ActivityBuilderHelper.cs
- XamlTreeBuilderBamlRecordWriter.cs
- ParserHooks.cs
- ScrollEvent.cs
- AngleUtil.cs
- DataTableExtensions.cs
- Primitive.cs
- StrokeDescriptor.cs
- PathSegmentCollection.cs
- SystemIPGlobalProperties.cs
- ActivityExecutionFilter.cs
- COAUTHINFO.cs
- HtmlTableCellCollection.cs
- SessionStateModule.cs
- FlowSwitchDesigner.xaml.cs
- RijndaelCryptoServiceProvider.cs
- RepeaterItemCollection.cs
- BitmapEffectDrawingContextState.cs
- SplitterCancelEvent.cs
- DependencyPropertyConverter.cs
- ResourceExpression.cs
- StorageComplexTypeMapping.cs
- HyperlinkAutomationPeer.cs
- precedingquery.cs
- TemplateControlCodeDomTreeGenerator.cs
- DynamicResourceExtensionConverter.cs
- DefinitionUpdate.cs
- CustomCategoryAttribute.cs
- ConvertBinder.cs
- TraceHandlerErrorFormatter.cs
- AmbientLight.cs
- MenuEventArgs.cs
- Column.cs
- ExpandoClass.cs
- XmlSchemaComplexContent.cs
- DynamicFilterExpression.cs
- TraceSwitch.cs
- VisualStyleTypesAndProperties.cs
- DbParameterHelper.cs
- DecimalAnimationUsingKeyFrames.cs
- EventsTab.cs
- XmlSchemaSimpleContent.cs
- SparseMemoryStream.cs
- ProviderCollection.cs
- ViewKeyConstraint.cs
- UnsafeNativeMethods.cs
- BitStream.cs
- EventPropertyMap.cs
- ConditionCollection.cs
- XmlDictionaryReaderQuotas.cs
- FileIOPermission.cs
- FontUnit.cs
- AttachedAnnotationChangedEventArgs.cs
- ClickablePoint.cs
- SchemaImporterExtensionElement.cs
- SqlClientFactory.cs
- LogPolicy.cs