Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- Intellisense.cs
- DescendentsWalker.cs
- XmlComplianceUtil.cs
- OrderedHashRepartitionEnumerator.cs
- Graphics.cs
- MatrixAnimationUsingKeyFrames.cs
- FailedToStartupUIException.cs
- RelatedEnd.cs
- Vector3DIndependentAnimationStorage.cs
- TreeNodeSelectionProcessor.cs
- List.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- EventWaitHandleSecurity.cs
- Matrix3DStack.cs
- ColorKeyFrameCollection.cs
- MenuCommandsChangedEventArgs.cs
- InternalMappingException.cs
- MSAANativeProvider.cs
- EnumerableWrapperWeakToStrong.cs
- _AutoWebProxyScriptWrapper.cs
- GeometryModel3D.cs
- DrawingVisualDrawingContext.cs
- StrongNameIdentityPermission.cs
- DesignerTransactionCloseEvent.cs
- SqlOuterApplyReducer.cs
- PreservationFileReader.cs
- SiteOfOriginContainer.cs
- PrintingPermissionAttribute.cs
- ManipulationDevice.cs
- DataGridViewComponentPropertyGridSite.cs
- XsltCompileContext.cs
- Blend.cs
- HtmlContainerControl.cs
- ContainerTracking.cs
- KeyProperty.cs
- LowerCaseStringConverter.cs
- SqlBulkCopyColumnMapping.cs
- UnsafeNativeMethods.cs
- ReflectionHelper.cs
- AuthorizationRuleCollection.cs
- oledbconnectionstring.cs
- RelationshipConverter.cs
- MethodCallTranslator.cs
- XmlReflectionImporter.cs
- AssemblyName.cs
- WCFModelStrings.Designer.cs
- BasicExpressionVisitor.cs
- ByteAnimationBase.cs
- ColumnWidthChangedEvent.cs
- ListControl.cs
- PreviewKeyDownEventArgs.cs
- RawStylusSystemGestureInputReport.cs
- TreeNodeConverter.cs
- ProtectedProviderSettings.cs
- GroupBoxRenderer.cs
- DataPagerFieldCollection.cs
- Positioning.cs
- QueryOptionExpression.cs
- FixedSOMPageElement.cs
- ClientSideQueueItem.cs
- UrlPath.cs
- HtmlShimManager.cs
- MobileUITypeEditor.cs
- LineMetrics.cs
- ContractCodeDomInfo.cs
- ErrorRuntimeConfig.cs
- GenericWebPart.cs
- DebugInfo.cs
- VariableReference.cs
- DrawingDrawingContext.cs
- FacetValueContainer.cs
- SelectionEditingBehavior.cs
- EventsTab.cs
- NativeCompoundFileAPIs.cs
- FlowSwitch.cs
- OdbcErrorCollection.cs
- ValidateNames.cs
- UserControlDocumentDesigner.cs
- EntityDataSourceQueryBuilder.cs
- ListBoxItem.cs
- AttachedPropertyBrowsableAttribute.cs
- ModulesEntry.cs
- FunctionNode.cs
- OutputCacheSection.cs
- HiddenFieldPageStatePersister.cs
- ManagedFilter.cs
- ProfilePropertySettings.cs
- RenderOptions.cs
- ServicePointManager.cs
- ComponentChangedEvent.cs
- DeviceContext2.cs
- XpsFont.cs
- WeakEventManager.cs
- XmlWriter.cs
- PointLightBase.cs
- Stroke2.cs
- FigureParaClient.cs
- AnonymousIdentificationSection.cs
- WindowHideOrCloseTracker.cs
- Int16Converter.cs