Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Configuration / System / Configuration / TimeSpanSecondsOrInfiniteConverter.cs / 1 / TimeSpanSecondsOrInfiniteConverter.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 TimeSpanSecondsOrInfiniteConverter : TimeSpanSecondsConverter { 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") { 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 TimeSpanSecondsOrInfiniteConverter : TimeSpanSecondsConverter { 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") { 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
- DateTimeStorage.cs
- KeyboardNavigation.cs
- CredentialCache.cs
- MiniConstructorInfo.cs
- ValueTable.cs
- HotSpot.cs
- IntAverageAggregationOperator.cs
- IndexingContentUnit.cs
- InstrumentationTracker.cs
- FederatedMessageSecurityOverHttpElement.cs
- ProtocolViolationException.cs
- DesignTimeParseData.cs
- Directory.cs
- CngProperty.cs
- KeyMatchBuilder.cs
- DbMetaDataCollectionNames.cs
- AppSettingsExpressionBuilder.cs
- GraphicsContainer.cs
- UmAlQuraCalendar.cs
- TabControlEvent.cs
- ExpressionEditorSheet.cs
- GeneralTransformCollection.cs
- ListItemCollection.cs
- SurrogateEncoder.cs
- HttpCapabilitiesEvaluator.cs
- AffineTransform3D.cs
- MultipartContentParser.cs
- OleDbRowUpdatedEvent.cs
- sqlser.cs
- MarkupExtensionParser.cs
- DataGridAutomationPeer.cs
- AddDataControlFieldDialog.cs
- Graphics.cs
- Fault.cs
- DefaultValueConverter.cs
- FlowLayoutPanelDesigner.cs
- XmlSchemaExporter.cs
- Operand.cs
- ElapsedEventArgs.cs
- DataGridViewColumnEventArgs.cs
- _DomainName.cs
- BookmarkTable.cs
- DataRowCollection.cs
- BackStopAuthenticationModule.cs
- xsdvalidator.cs
- InstanceDataCollectionCollection.cs
- CodeConstructor.cs
- PersonalizationAdministration.cs
- shaperfactory.cs
- WindowsListViewGroupSubsetLink.cs
- ContactManager.cs
- GridViewAutomationPeer.cs
- ListMarkerSourceInfo.cs
- ObjectAnimationUsingKeyFrames.cs
- MasterPageBuildProvider.cs
- WebWorkflowRole.cs
- HeaderElement.cs
- PageBuildProvider.cs
- JsonWriter.cs
- COM2IDispatchConverter.cs
- InstanceLockQueryResult.cs
- CalendarItem.cs
- SoapIgnoreAttribute.cs
- NavigationPropertyEmitter.cs
- SQLRoleProvider.cs
- TranslateTransform3D.cs
- GlyphCollection.cs
- QueryResponse.cs
- BaseDataBoundControlDesigner.cs
- XmlTypeAttribute.cs
- ColumnWidthChangedEvent.cs
- AsyncPostBackTrigger.cs
- DataStorage.cs
- NeutralResourcesLanguageAttribute.cs
- ActiveXHost.cs
- CodeMemberProperty.cs
- CodePageUtils.cs
- SettingsProperty.cs
- Unit.cs
- MouseDevice.cs
- PropertyReferenceSerializer.cs
- NullableLongSumAggregationOperator.cs
- TemplateBuilder.cs
- DesignerTransaction.cs
- SqlTriggerAttribute.cs
- PageParser.cs
- _TimerThread.cs
- ResourceReferenceExpressionConverter.cs
- TailPinnedEventArgs.cs
- DataGridPageChangedEventArgs.cs
- EdmType.cs
- MeshGeometry3D.cs
- Wizard.cs
- DetailsViewInsertedEventArgs.cs
- DbDataRecord.cs
- FileDataSourceCache.cs
- ConsoleTraceListener.cs
- FastEncoder.cs
- StringConcat.cs
- TextRangeEditTables.cs