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
- AssemblyBuilder.cs
- SliderAutomationPeer.cs
- Tokenizer.cs
- MembershipPasswordException.cs
- AdRotator.cs
- XPathAncestorIterator.cs
- DataObjectMethodAttribute.cs
- MenuStrip.cs
- DefaultIfEmptyQueryOperator.cs
- EndpointDispatcherTable.cs
- MetaForeignKeyColumn.cs
- RegionData.cs
- DelimitedListTraceListener.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- MetadataArtifactLoaderComposite.cs
- BitmapMetadataBlob.cs
- DatasetMethodGenerator.cs
- ColorKeyFrameCollection.cs
- ImageCodecInfoPrivate.cs
- DataTemplate.cs
- ClientCultureInfo.cs
- DirectoryObjectSecurity.cs
- DoubleKeyFrameCollection.cs
- ChtmlTextWriter.cs
- UriGenerator.cs
- FormViewInsertedEventArgs.cs
- DataTableNewRowEvent.cs
- EasingKeyFrames.cs
- PixelShader.cs
- WebPartConnection.cs
- SyntaxCheck.cs
- NamedPipeTransportElement.cs
- TemplateBamlTreeBuilder.cs
- CodeTypeReference.cs
- SqlSupersetValidator.cs
- SafeEventLogWriteHandle.cs
- TraceAsyncResult.cs
- ISAPIWorkerRequest.cs
- XmlSchemaExporter.cs
- DesignerDataView.cs
- BitmapEffectDrawing.cs
- DesignSurface.cs
- TileBrush.cs
- MemberRelationshipService.cs
- CheckBoxBaseAdapter.cs
- NavigationHelper.cs
- Point.cs
- AbstractSvcMapFileLoader.cs
- CodeTypeDelegate.cs
- HtmlTernaryTree.cs
- FacetEnabledSchemaElement.cs
- XPathException.cs
- ComponentCodeDomSerializer.cs
- LineBreakRecord.cs
- DataGridViewColumn.cs
- DiagnosticTraceSource.cs
- Invariant.cs
- ExceptionUtil.cs
- XmlQueryTypeFactory.cs
- FileSystemInfo.cs
- InputLanguageEventArgs.cs
- HashRepartitionEnumerator.cs
- LineSegment.cs
- FormsAuthentication.cs
- DatePickerDateValidationErrorEventArgs.cs
- XamlTypeMapper.cs
- ListChangedEventArgs.cs
- ToolStripPanel.cs
- MissingManifestResourceException.cs
- HyperLinkField.cs
- RadioButton.cs
- SystemIPGlobalStatistics.cs
- DocumentReferenceCollection.cs
- CompoundFileStorageReference.cs
- OdbcPermission.cs
- XmlSubtreeReader.cs
- WSSecurityTokenSerializer.cs
- MetafileHeaderWmf.cs
- Int16.cs
- ScaleTransform.cs
- ListViewItem.cs
- SignatureDescription.cs
- Descriptor.cs
- QueryResult.cs
- ProviderManager.cs
- Propagator.Evaluator.cs
- XPathNavigatorReader.cs
- XmlLoader.cs
- PolyBezierSegmentFigureLogic.cs
- LiteralTextContainerControlBuilder.cs
- DefaultMemberAttribute.cs
- ImmutableDispatchRuntime.cs
- CalculatedColumn.cs
- RequestQueue.cs
- ObjectIDGenerator.cs
- CqlLexerHelpers.cs
- GC.cs
- Utils.cs
- PropertyDescriptorCollection.cs