Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Configuration / System / Configuration / TimeSpanMinutesConverter.cs / 1 / TimeSpanMinutesConverter.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 TimeSpanMinutesConverter : ConfigurationConverterBase {
public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) {
ValidateType(value, typeof(TimeSpan));
long data = (long)(((TimeSpan)value).TotalMinutes);
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 = long.Parse((string)data, CultureInfo.InvariantCulture);
return TimeSpan.FromMinutes((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 TimeSpanMinutesConverter : ConfigurationConverterBase {
public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type) {
ValidateType(value, typeof(TimeSpan));
long data = (long)(((TimeSpan)value).TotalMinutes);
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 = long.Parse((string)data, CultureInfo.InvariantCulture);
return TimeSpan.FromMinutes((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
- EndpointFilterProvider.cs
- ReliabilityContractAttribute.cs
- RunClient.cs
- DataGridViewButtonCell.cs
- CacheDependency.cs
- ContextMenuStrip.cs
- SessionStateContainer.cs
- WhileDesigner.xaml.cs
- ToolboxItemFilterAttribute.cs
- SqlServices.cs
- DES.cs
- OpenFileDialog.cs
- BinaryMethodMessage.cs
- PrintEvent.cs
- GcHandle.cs
- ToolStripSystemRenderer.cs
- DataRowChangeEvent.cs
- ProfessionalColors.cs
- CopyAttributesAction.cs
- TypeCacheManager.cs
- RestHandlerFactory.cs
- CodeValidator.cs
- RNGCryptoServiceProvider.cs
- HtmlElementCollection.cs
- DrawingGroup.cs
- DependencySource.cs
- PeerCollaborationPermission.cs
- VectorConverter.cs
- TreeViewItemAutomationPeer.cs
- PropertyTab.cs
- LiteralControl.cs
- ListBindableAttribute.cs
- WindowsFont.cs
- TrustSection.cs
- CultureInfoConverter.cs
- BinaryObjectWriter.cs
- CompiledRegexRunnerFactory.cs
- ItemAutomationPeer.cs
- Merger.cs
- SqlNodeTypeOperators.cs
- DefaultAuthorizationContext.cs
- DesignerAdapterAttribute.cs
- PlainXmlWriter.cs
- PropertyEntry.cs
- ConsoleKeyInfo.cs
- XPathDocumentNavigator.cs
- HostProtectionException.cs
- Focus.cs
- KoreanCalendar.cs
- URLAttribute.cs
- SiteMapSection.cs
- PagerSettings.cs
- WebPartZoneDesigner.cs
- httpserverutility.cs
- WebResponse.cs
- SwitchLevelAttribute.cs
- DataGridRowHeader.cs
- ChannelServices.cs
- MergablePropertyAttribute.cs
- JournalEntryStack.cs
- BinaryCommonClasses.cs
- DependencyPropertyAttribute.cs
- SecurityContext.cs
- XmlWrappingWriter.cs
- BlobPersonalizationState.cs
- BamlRecordHelper.cs
- CurrencyWrapper.cs
- HtmlDocument.cs
- Int32Animation.cs
- Logging.cs
- NavigationProgressEventArgs.cs
- ObjectCacheSettings.cs
- DoubleConverter.cs
- COM2IPerPropertyBrowsingHandler.cs
- PeerSecurityManager.cs
- SimpleNameService.cs
- InheritanceContextChangedEventManager.cs
- CodeTypeReference.cs
- ContextMenuService.cs
- InkCanvas.cs
- EventNotify.cs
- XPathScanner.cs
- ParameterExpression.cs
- SystemEvents.cs
- WebBrowserProgressChangedEventHandler.cs
- ButtonBaseAdapter.cs
- AnimationTimeline.cs
- FlowLayout.cs
- RIPEMD160Managed.cs
- ErrorStyle.cs
- PermissionSetTriple.cs
- PtsCache.cs
- EncodingDataItem.cs
- AuthorizationRule.cs
- SystemIPv4InterfaceProperties.cs
- GeometryDrawing.cs
- AdapterDictionary.cs
- CubicEase.cs
- HyperLink.cs
- ZipPackagePart.cs