Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / TimeSpanSecondsConverter.cs / 1305376 / TimeSpanSecondsConverter.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 class TimeSpanSecondsConverter : ConfigurationConverterBase { public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) { ValidateType(value, typeof(TimeSpan)); long data = (long)(((TimeSpan)value).TotalSeconds); return data.ToString(CultureInfo.InvariantCulture); } public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data) { Debug.Assert(data is string, "data is string"); long min = 0; try { min = long.Parse((string)data, CultureInfo.InvariantCulture); } catch { throw new ArgumentException(SR.GetString(SR.Converter_timespan_not_in_second)); } return TimeSpan.FromSeconds((double)min); } } } // 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
- DataGridViewRowDividerDoubleClickEventArgs.cs
- DirectionalLight.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- OdbcConnectionHandle.cs
- Classification.cs
- ItemContainerPattern.cs
- DayRenderEvent.cs
- RegexMatch.cs
- WindowAutomationPeer.cs
- TreeViewCancelEvent.cs
- SelectionItemProviderWrapper.cs
- Main.cs
- PrinterResolution.cs
- DocumentPageViewAutomationPeer.cs
- PrintDialog.cs
- RawMouseInputReport.cs
- Camera.cs
- Timer.cs
- ISAPIWorkerRequest.cs
- SqlCharStream.cs
- DataGridViewControlCollection.cs
- ThreadNeutralSemaphore.cs
- Util.cs
- PartialCachingControl.cs
- TableParaClient.cs
- Dispatcher.cs
- RawStylusActions.cs
- TableCellAutomationPeer.cs
- LiteralControl.cs
- Transactions.cs
- JsonObjectDataContract.cs
- BasicViewGenerator.cs
- Splitter.cs
- ReadOnlyObservableCollection.cs
- RenderData.cs
- WindowsGrip.cs
- XmlException.cs
- OdbcException.cs
- DecoderExceptionFallback.cs
- NopReturnReader.cs
- CodeTypeReferenceCollection.cs
- WebPartConnectionsConfigureVerb.cs
- RegexGroupCollection.cs
- XPathNavigatorReader.cs
- XpsS0ValidatingLoader.cs
- HttpCachePolicy.cs
- SystemInformation.cs
- Substitution.cs
- IgnorePropertiesAttribute.cs
- BufferedWebEventProvider.cs
- HttpErrorTraceRecord.cs
- RoleProviderPrincipal.cs
- codemethodreferenceexpression.cs
- CapabilitiesState.cs
- DesignerActionUIStateChangeEventArgs.cs
- FilterException.cs
- NotConverter.cs
- StrongName.cs
- DataListDesigner.cs
- SerialStream.cs
- ToolStripGrip.cs
- LambdaCompiler.Binary.cs
- AssociationTypeEmitter.cs
- SingleTagSectionHandler.cs
- WebPartDisplayMode.cs
- TypeDescriptionProvider.cs
- CustomWebEventKey.cs
- SiteMap.cs
- ConnectionStringSettings.cs
- HttpModuleAction.cs
- SQLInt64.cs
- Error.cs
- WebScriptMetadataInstanceContextProvider.cs
- IdentityManager.cs
- ChangeInterceptorAttribute.cs
- CommandHelper.cs
- httpserverutility.cs
- ByteAnimation.cs
- UnauthorizedWebPart.cs
- RightsManagementPermission.cs
- MenuAdapter.cs
- ToolStripItemClickedEventArgs.cs
- GCHandleCookieTable.cs
- SafeProcessHandle.cs
- ToolStripItemRenderEventArgs.cs
- ResourceReferenceExpression.cs
- mediaeventargs.cs
- ApplicationHost.cs
- SafePEFileHandle.cs
- DebugView.cs
- ObservableCollectionDefaultValueFactory.cs
- XamlPathDataSerializer.cs
- ContainerUIElement3D.cs
- Signature.cs
- PropertyValueUIItem.cs
- SoapAttributeAttribute.cs
- ChannelServices.cs
- PersonalizableTypeEntry.cs
- IndentedWriter.cs
- _Rfc2616CacheValidators.cs