Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / TimeSpanMinutesOrInfiniteConverter.cs / 1305376 / TimeSpanMinutesOrInfiniteConverter.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 TimeSpanMinutesOrInfiniteConverter : TimeSpanMinutesConverter { 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 base.ConvertTo(ctx, ci, value, type); } } public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) { Debug.Assert(data is string, "data is string"); if ((string)data == "Infinite") { // The "infinite" value is the max minutes a int can hold return TimeSpan.MaxValue; } else { return base.ConvertFrom(ctx, ci, 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 TimeSpanMinutesOrInfiniteConverter : TimeSpanMinutesConverter { 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 base.ConvertTo(ctx, ci, value, type); } } public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) { Debug.Assert(data is string, "data is string"); if ((string)data == "Infinite") { // The "infinite" value is the max minutes a int can hold return TimeSpan.MaxValue; } else { return base.ConvertFrom(ctx, ci, 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
- TypeProvider.cs
- ControlEvent.cs
- Literal.cs
- MethodImplAttribute.cs
- PriorityItem.cs
- QueryResults.cs
- SecurityState.cs
- LinqDataSource.cs
- DragCompletedEventArgs.cs
- DrawingContextWalker.cs
- Help.cs
- Padding.cs
- Block.cs
- TransformValueSerializer.cs
- Drawing.cs
- WebMessageFormatHelper.cs
- SqlCacheDependencyDatabaseCollection.cs
- ResourceAssociationType.cs
- CryptoHelper.cs
- ModelPropertyImpl.cs
- RectangleF.cs
- OdbcParameterCollection.cs
- StaticExtension.cs
- InputLanguage.cs
- TreeNodeBinding.cs
- ByteAnimation.cs
- ResourceType.cs
- ProcessHostMapPath.cs
- ConnectionProviderAttribute.cs
- IntSecurity.cs
- DrawingAttributesDefaultValueFactory.cs
- BigInt.cs
- TemplateBaseAction.cs
- FixedDSBuilder.cs
- KeyedPriorityQueue.cs
- RelOps.cs
- SaveFileDialog.cs
- RelOps.cs
- WorkflowMarkupSerializationException.cs
- ComplexPropertyEntry.cs
- ToolStripDropDownButton.cs
- StopStoryboard.cs
- MessageBox.cs
- SevenBitStream.cs
- NullableIntAverageAggregationOperator.cs
- invalidudtexception.cs
- _IPv6Address.cs
- TCPClient.cs
- BrowserTree.cs
- AttributeCollection.cs
- EnlistmentTraceIdentifier.cs
- Operator.cs
- SecurityManager.cs
- ChildTable.cs
- PictureBox.cs
- RightsManagementPermission.cs
- EntityClientCacheEntry.cs
- FixedPage.cs
- RegexMatch.cs
- ChtmlTextWriter.cs
- CodeIdentifier.cs
- PingOptions.cs
- TraceEventCache.cs
- GlobalProxySelection.cs
- HtmlLink.cs
- QilGenerator.cs
- HtmlTableCellCollection.cs
- IxmlLineInfo.cs
- ComponentResourceKeyConverter.cs
- ComponentConverter.cs
- Token.cs
- ResourceManagerWrapper.cs
- LoginName.cs
- Stackframe.cs
- ObjectSecurityT.cs
- Buffer.cs
- AppDomain.cs
- XmlAnyElementAttribute.cs
- ExceptionUtility.cs
- PingOptions.cs
- TypeLibConverter.cs
- DataSetUtil.cs
- RegexGroup.cs
- SimpleWebHandlerParser.cs
- NameValueConfigurationElement.cs
- XappLauncher.cs
- SynthesizerStateChangedEventArgs.cs
- ProcessProtocolHandler.cs
- AssertHelper.cs
- MetaType.cs
- UnsafeNativeMethods.cs
- XmlCountingReader.cs
- Keywords.cs
- DateTimeAutomationPeer.cs
- XmlEncodedRawTextWriter.cs
- WebConfigurationManager.cs
- DataGridRow.cs
- BoundsDrawingContextWalker.cs
- BitmapEffectInput.cs
- GenerateTemporaryTargetAssembly.cs