Code:
/ 4.0 / 4.0 / 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. //------------------------------------------------------------------------------ //// 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
- FusionWrap.cs
- Item.cs
- FontSource.cs
- Publisher.cs
- ArcSegment.cs
- WebPartsPersonalization.cs
- XmlSchemaSubstitutionGroup.cs
- FlagsAttribute.cs
- NumberSubstitution.cs
- DataProtectionSecurityStateEncoder.cs
- XmlStreamStore.cs
- CriticalHandle.cs
- Pool.cs
- WorkflowDesignerColors.cs
- DynamicValidatorEventArgs.cs
- TemplateManager.cs
- TemplateComponentConnector.cs
- LiteralLink.cs
- ContentOperations.cs
- EntityKeyElement.cs
- FileFormatException.cs
- Table.cs
- basecomparevalidator.cs
- ServiceElementCollection.cs
- TextSpan.cs
- TextProperties.cs
- XamlRtfConverter.cs
- DataBoundLiteralControl.cs
- MailMessageEventArgs.cs
- NavigationCommands.cs
- ServiceChannelProxy.cs
- DataBindingHandlerAttribute.cs
- SerializationSectionGroup.cs
- OutKeywords.cs
- Baml2006SchemaContext.cs
- TdsParserSessionPool.cs
- ListView.cs
- RtfToken.cs
- SqlErrorCollection.cs
- MarkedHighlightComponent.cs
- EnumBuilder.cs
- SBCSCodePageEncoding.cs
- InputElement.cs
- DataGridViewImageCell.cs
- ListViewTableRow.cs
- RC2.cs
- UnitySerializationHolder.cs
- TextDpi.cs
- EditorPartCollection.cs
- SingleStorage.cs
- SystemIPGlobalStatistics.cs
- MasterPageBuildProvider.cs
- BindingSource.cs
- XmlNamespaceMappingCollection.cs
- DllNotFoundException.cs
- URL.cs
- SafeCryptContextHandle.cs
- FullTrustAssemblyCollection.cs
- MimeTypePropertyAttribute.cs
- OutputCacheSection.cs
- ObjectContext.cs
- VerificationException.cs
- InlineObject.cs
- DoubleLink.cs
- ChannelFactory.cs
- XPathDocumentNavigator.cs
- ControlPager.cs
- UnsettableComboBox.cs
- MessageOperationFormatter.cs
- InternalCache.cs
- ParameterReplacerVisitor.cs
- PreservationFileWriter.cs
- MetadataImporterQuotas.cs
- SystemResources.cs
- OdbcConnection.cs
- TypedReference.cs
- ContextMenuService.cs
- XPathDocumentNavigator.cs
- RtfControls.cs
- TemplateControlCodeDomTreeGenerator.cs
- CodeTypeReferenceExpression.cs
- ScrollItemProviderWrapper.cs
- FormatterServices.cs
- XmlSchemaSet.cs
- ListViewItemCollectionEditor.cs
- Literal.cs
- COAUTHINFO.cs
- ClientScriptManagerWrapper.cs
- CachingHintValidation.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- PlanCompiler.cs
- LinqToSqlWrapper.cs
- StylusOverProperty.cs
- Tablet.cs
- CompositionTarget.cs
- HyperLinkStyle.cs
- WrappedDispatcherException.cs
- uribuilder.cs
- SqlCommandBuilder.cs
- MimeMultiPart.cs