Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Configuration / System / Configuration / InfiniteTimeSpanConverter.cs / 1 / InfiniteTimeSpanConverter.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 InfiniteTimeSpanConverter : ConfigurationConverterBase {
static readonly TypeConverter s_TimeSpanConverter = TypeDescriptor.GetConverter(typeof(TimeSpan));
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 s_TimeSpanConverter.ConvertToInvariantString(value);
}
}
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 s_TimeSpanConverter.ConvertFromInvariantString((string)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 InfiniteTimeSpanConverter : ConfigurationConverterBase {
static readonly TypeConverter s_TimeSpanConverter = TypeDescriptor.GetConverter(typeof(TimeSpan));
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 s_TimeSpanConverter.ConvertToInvariantString(value);
}
}
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 s_TimeSpanConverter.ConvertFromInvariantString((string)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
- DocumentCollection.cs
- DefaultEvaluationContext.cs
- ToolStripProfessionalLowResolutionRenderer.cs
- ContentHostHelper.cs
- FormsAuthenticationEventArgs.cs
- AsyncStreamReader.cs
- TriggerActionCollection.cs
- Pointer.cs
- SqlGatherProducedAliases.cs
- XmlMemberMapping.cs
- InlineObject.cs
- MenuRenderer.cs
- SerializationStore.cs
- XamlWriter.cs
- MethodBuilder.cs
- ConnectionPoolManager.cs
- PropertyKey.cs
- BindToObject.cs
- SwitchAttribute.cs
- StyleBamlTreeBuilder.cs
- AliasExpr.cs
- XamlBrushSerializer.cs
- MimeObjectFactory.cs
- HTTPNotFoundHandler.cs
- CodeDelegateInvokeExpression.cs
- OutputCacheProfileCollection.cs
- SqlDataSourceSelectingEventArgs.cs
- RichTextBoxContextMenu.cs
- AppendHelper.cs
- AutomationElementCollection.cs
- HttpWebRequestElement.cs
- OAVariantLib.cs
- IndexerNameAttribute.cs
- counter.cs
- TextureBrush.cs
- DateTimeFormatInfo.cs
- HandleCollector.cs
- GridSplitterAutomationPeer.cs
- SecurityTokenProvider.cs
- SoapHeaders.cs
- MenuAdapter.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- ExtensionSurface.cs
- RecordConverter.cs
- StorageAssociationSetMapping.cs
- ToolStripInSituService.cs
- PathSegment.cs
- SHA384Managed.cs
- GridViewRowPresenterBase.cs
- TextRange.cs
- FixedSOMGroup.cs
- BamlWriter.cs
- TypeBinaryExpression.cs
- OLEDB_Util.cs
- HtmlCommandAdapter.cs
- ImmutableAssemblyCacheEntry.cs
- QueryInterceptorAttribute.cs
- DictionaryContent.cs
- HierarchicalDataSourceConverter.cs
- WmlPanelAdapter.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- ConfigurationElement.cs
- latinshape.cs
- OdbcConnection.cs
- HierarchicalDataBoundControl.cs
- ToolStripItemBehavior.cs
- Image.cs
- UInt32Converter.cs
- StructuralCache.cs
- WebBrowsableAttribute.cs
- SynchronizedInputAdaptor.cs
- IMembershipProvider.cs
- FixedPosition.cs
- SqlExpressionNullability.cs
- ViewUtilities.cs
- XPathDocument.cs
- MemberCollection.cs
- XmlArrayItemAttributes.cs
- XPathPatternParser.cs
- OpCopier.cs
- ThreadStaticAttribute.cs
- EventDrivenDesigner.cs
- ActivityPreviewDesigner.cs
- PresentationSource.cs
- OLEDB_Util.cs
- FlatButtonAppearance.cs
- SpellerError.cs
- DataGridViewIntLinkedList.cs
- DispatcherFrame.cs
- SmtpDigestAuthenticationModule.cs
- RuleSetCollection.cs
- XNodeSchemaApplier.cs
- CryptoStream.cs
- ArraySortHelper.cs
- SimpleWorkerRequest.cs
- DynamicExpression.cs
- MouseBinding.cs
- XmlSchemaAnyAttribute.cs
- CommonObjectSecurity.cs
- CqlParser.cs