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
- ControlType.cs
- SafeRightsManagementQueryHandle.cs
- shaperfactoryquerycachekey.cs
- WebServiceHostFactory.cs
- DeclarationUpdate.cs
- SimpleWorkerRequest.cs
- StringOutput.cs
- UnsafeNativeMethods.cs
- ConfigurationPropertyAttribute.cs
- EventTask.cs
- ComboBox.cs
- ExpressionBindingCollection.cs
- EventHandlingScope.cs
- GroupQuery.cs
- KnownAssemblyEntry.cs
- SetIndexBinder.cs
- FormParameter.cs
- WebPartTracker.cs
- UrlAuthorizationModule.cs
- oledbmetadatacollectionnames.cs
- ManualResetEvent.cs
- TreePrinter.cs
- TypeUtil.cs
- FormsAuthenticationEventArgs.cs
- DispatcherExceptionFilterEventArgs.cs
- EventLogConfiguration.cs
- Guid.cs
- SimpleTypesSurrogate.cs
- SchemaInfo.cs
- TreeBuilderBamlTranslator.cs
- HexParser.cs
- SafeFileMappingHandle.cs
- DbDataAdapter.cs
- SspiWrapper.cs
- OleDbRowUpdatingEvent.cs
- SpecularMaterial.cs
- NamedPipeConnectionPool.cs
- XmlWrappingWriter.cs
- ProviderUtil.cs
- Camera.cs
- DataObjectEventArgs.cs
- TextTreeTextBlock.cs
- StringCollection.cs
- FloatUtil.cs
- OracleConnectionStringBuilder.cs
- Permission.cs
- SelectingProviderEventArgs.cs
- ExpressionNode.cs
- SchemaInfo.cs
- DbConnectionInternal.cs
- SqlUDTStorage.cs
- IISUnsafeMethods.cs
- PowerModeChangedEventArgs.cs
- AdCreatedEventArgs.cs
- TaskDesigner.cs
- Item.cs
- SHA256.cs
- MemberAssignmentAnalysis.cs
- XmlChoiceIdentifierAttribute.cs
- HttpHandlersSection.cs
- RegionIterator.cs
- CodePageUtils.cs
- DynamicDataResources.Designer.cs
- Win32Exception.cs
- Rijndael.cs
- Menu.cs
- ContractBase.cs
- RemoteAsymmetricSignatureFormatter.cs
- WebContext.cs
- QilVisitor.cs
- StringExpressionSet.cs
- ServiceOperationHelpers.cs
- WebPartConnectionsDisconnectVerb.cs
- RunInstallerAttribute.cs
- HMACSHA1.cs
- NotImplementedException.cs
- NetTcpBindingElement.cs
- MsmqIntegrationValidationBehavior.cs
- KnownAssembliesSet.cs
- TaskHelper.cs
- SurrogateSelector.cs
- IndentedWriter.cs
- _SecureChannel.cs
- SemaphoreFullException.cs
- NullRuntimeConfig.cs
- CriticalExceptions.cs
- DataContractJsonSerializer.cs
- UrlMapping.cs
- ChangePassword.cs
- PKCS1MaskGenerationMethod.cs
- LinkLabel.cs
- ContentFilePart.cs
- CellQuery.cs
- COM2ExtendedTypeConverter.cs
- DbProviderConfigurationHandler.cs
- SocketPermission.cs
- AssemblyHash.cs
- RepeatButtonAutomationPeer.cs
- SessionStateSection.cs
- SqlConnectionHelper.cs