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
- ReaderWriterLockSlim.cs
- SecurityContextSecurityTokenResolver.cs
- DataStreamFromComStream.cs
- SizeAnimationUsingKeyFrames.cs
- FrameworkElementFactoryMarkupObject.cs
- GC.cs
- AppDomainInstanceProvider.cs
- DataColumnMappingCollection.cs
- StylusPoint.cs
- SQLBinary.cs
- AggregateNode.cs
- RijndaelManaged.cs
- XDeferredAxisSource.cs
- Configuration.cs
- EdmItemCollection.cs
- RuleSettings.cs
- BamlStream.cs
- CompositeFontInfo.cs
- WinFormsUtils.cs
- HandlerBase.cs
- RtfControlWordInfo.cs
- MemoryStream.cs
- shaperfactory.cs
- SQLByte.cs
- NativeMethods.cs
- ToolStripSplitButton.cs
- PromptEventArgs.cs
- CuspData.cs
- JsonUriDataContract.cs
- DynamicEndpoint.cs
- ImageCodecInfo.cs
- BamlLocalizableResource.cs
- SamlAdvice.cs
- GiveFeedbackEventArgs.cs
- XmlTextReaderImpl.cs
- KeyNotFoundException.cs
- DbConnectionHelper.cs
- storagemappingitemcollection.viewdictionary.cs
- ExecutorLocksHeldException.cs
- SplitterPanel.cs
- XmlSchemaSubstitutionGroup.cs
- HttpCacheVary.cs
- _LoggingObject.cs
- InputBuffer.cs
- TriggerBase.cs
- ProxyHelper.cs
- RSACryptoServiceProvider.cs
- SequentialWorkflowRootDesigner.cs
- StylusPlugInCollection.cs
- SchemaCollectionPreprocessor.cs
- SelectionProcessor.cs
- XsdValidatingReader.cs
- ADMembershipUser.cs
- Pair.cs
- BinaryParser.cs
- StreamWriter.cs
- PointConverter.cs
- CustomCategoryAttribute.cs
- XmlSerializationGeneratedCode.cs
- RuntimeHelpers.cs
- DockAndAnchorLayout.cs
- ListViewAutomationPeer.cs
- GenericXmlSecurityToken.cs
- Event.cs
- ColorMatrix.cs
- CaseExpr.cs
- MatrixIndependentAnimationStorage.cs
- SqlParameterizer.cs
- SignatureDescription.cs
- RuntimeConfigurationRecord.cs
- OutOfProcStateClientManager.cs
- SqlDependencyListener.cs
- OperatingSystem.cs
- MailMessageEventArgs.cs
- TargetControlTypeAttribute.cs
- XslAst.cs
- DesignerActionItemCollection.cs
- MSAAEventDispatcher.cs
- RealProxy.cs
- Rotation3D.cs
- wmiprovider.cs
- CheckBoxList.cs
- MenuEventArgs.cs
- XsdDateTime.cs
- SafeLocalAllocation.cs
- CryptoKeySecurity.cs
- BooleanProjectedSlot.cs
- AttachedAnnotation.cs
- Pair.cs
- SyntaxCheck.cs
- RawStylusInputCustomData.cs
- DataTransferEventArgs.cs
- Track.cs
- PointCollection.cs
- AccessorTable.cs
- PackageDigitalSignatureManager.cs
- ConfigXmlWhitespace.cs
- HtmlCalendarAdapter.cs
- XmlAnyAttributeAttribute.cs
- TemporaryBitmapFile.cs