Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Configuration / System / Configuration / TimeSpanSecondsConverter.cs / 1 / 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
- ToolStripItemTextRenderEventArgs.cs
- ToolBarOverflowPanel.cs
- BinaryMessageFormatter.cs
- DefaultAutoFieldGenerator.cs
- SpellerStatusTable.cs
- ParamArrayAttribute.cs
- XslAstAnalyzer.cs
- TransactionScopeDesigner.cs
- EntityKey.cs
- TraceSwitch.cs
- AttributedMetaModel.cs
- Point.cs
- QilExpression.cs
- TreeWalkHelper.cs
- RtfNavigator.cs
- ValueQuery.cs
- LayoutTable.cs
- CollectionViewGroup.cs
- ErrorFormatterPage.cs
- hwndwrapper.cs
- TypeResolver.cs
- HttpBrowserCapabilitiesWrapper.cs
- WindowsComboBox.cs
- InterleavedZipPartStream.cs
- FileVersion.cs
- IsolatedStorageException.cs
- AddingNewEventArgs.cs
- DataListDesigner.cs
- MultiPageTextView.cs
- AbstractExpressions.cs
- _HelperAsyncResults.cs
- xsdvalidator.cs
- InputBindingCollection.cs
- DbgUtil.cs
- SmiConnection.cs
- SubtreeProcessor.cs
- ConfigXmlAttribute.cs
- JavaScriptSerializer.cs
- EntityDataSource.cs
- MinimizableAttributeTypeConverter.cs
- PhysicalAddress.cs
- FormsAuthenticationUserCollection.cs
- DirectoryInfo.cs
- DrawingAttributes.cs
- TemplatedMailWebEventProvider.cs
- FontFamilyIdentifier.cs
- WebBrowserHelper.cs
- ComponentChangedEvent.cs
- TemplateBuilder.cs
- SByteStorage.cs
- KerberosRequestorSecurityToken.cs
- InputScope.cs
- ReversePositionQuery.cs
- DBDataPermission.cs
- WindowsStatusBar.cs
- ContextMenuStripGroup.cs
- DeviceFiltersSection.cs
- FontFaceLayoutInfo.cs
- MdiWindowListStrip.cs
- VersionedStreamOwner.cs
- querybuilder.cs
- DataGridTextBoxColumn.cs
- SafeSystemMetrics.cs
- PerformanceCountersElement.cs
- Stream.cs
- ResourceDictionaryCollection.cs
- LinqTreeNodeEvaluator.cs
- Dispatcher.cs
- Compress.cs
- HwndMouseInputProvider.cs
- PrePrepareMethodAttribute.cs
- OrderByQueryOptionExpression.cs
- XmlEntity.cs
- ConfigurationErrorsException.cs
- EditorPartCollection.cs
- SolidColorBrush.cs
- TransformerInfo.cs
- GlobalAclOperationRequirement.cs
- XmlSerializerVersionAttribute.cs
- parserscommon.cs
- DebugInfoGenerator.cs
- DoubleLink.cs
- SingleQueryOperator.cs
- DBPropSet.cs
- PackagePart.cs
- CacheChildrenQuery.cs
- DataGridViewToolTip.cs
- SessionEndingEventArgs.cs
- InstanceKeyNotReadyException.cs
- ZipIOLocalFileHeader.cs
- TextTreeDeleteContentUndoUnit.cs
- _HeaderInfoTable.cs
- ActivityXamlServices.cs
- NumericUpDown.cs
- ChineseLunisolarCalendar.cs
- CompareValidator.cs
- DragDropManager.cs
- ContentElement.cs
- Visual3D.cs
- OleDbConnectionInternal.cs