Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / TimeSpanMinutesConverter.cs / 1305376 / 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
- SqlBooleanizer.cs
- WinFormsComponentEditor.cs
- GeneralTransform3DCollection.cs
- ActivityDelegate.cs
- RuleRef.cs
- TreeNode.cs
- WorkflowExecutor.cs
- objectresult_tresulttype.cs
- CachingHintValidation.cs
- SettingsAttributeDictionary.cs
- EntityClientCacheKey.cs
- AnonymousIdentificationSection.cs
- Error.cs
- PassportAuthenticationModule.cs
- PersonalizationStateInfoCollection.cs
- User.cs
- CacheHelper.cs
- compensatingcollection.cs
- Message.cs
- dbdatarecord.cs
- SystemNetworkInterface.cs
- AssemblyAttributesGoHere.cs
- DesignerOptionService.cs
- XpsSerializerFactory.cs
- TemplateComponentConnector.cs
- CultureMapper.cs
- Typography.cs
- FlatButtonAppearance.cs
- DispatcherSynchronizationContext.cs
- BitmapEffectDrawingContent.cs
- CodeTypeReference.cs
- GridToolTip.cs
- DesignerAdapterAttribute.cs
- PingReply.cs
- ControlPropertyNameConverter.cs
- RuleInfoComparer.cs
- WorkflowRuntimeServiceElementCollection.cs
- SymbolTable.cs
- ControlCollection.cs
- Point3DAnimationUsingKeyFrames.cs
- ToolStripManager.cs
- Int32Rect.cs
- JsonReaderWriterFactory.cs
- StructuredTypeInfo.cs
- Queue.cs
- WindowShowOrOpenTracker.cs
- ApplyTemplatesAction.cs
- QilExpression.cs
- DES.cs
- CodeSnippetStatement.cs
- XmlSchemaAttribute.cs
- TypeBrowserDialog.cs
- Rect.cs
- DiscoveryViaBehavior.cs
- AccessedThroughPropertyAttribute.cs
- KeyConverter.cs
- RIPEMD160Managed.cs
- DEREncoding.cs
- LineServices.cs
- OptionUsage.cs
- ObservableCollection.cs
- PersonalizationProviderCollection.cs
- MsdtcClusterUtils.cs
- FileVersionInfo.cs
- LifetimeServices.cs
- CookielessHelper.cs
- WebPartMovingEventArgs.cs
- RelativeSource.cs
- DataViewSetting.cs
- TaskbarItemInfo.cs
- LinkedResourceCollection.cs
- ColorAnimationUsingKeyFrames.cs
- BinaryCommonClasses.cs
- ArraySegment.cs
- ErrorFormatterPage.cs
- DbXmlEnabledProviderManifest.cs
- TargetException.cs
- TextParagraphCache.cs
- EntitySqlQueryBuilder.cs
- CryptoApi.cs
- JulianCalendar.cs
- Typeface.cs
- CroppedBitmap.cs
- ObjectCloneHelper.cs
- MemoryPressure.cs
- StylusPointProperty.cs
- EastAsianLunisolarCalendar.cs
- MarkupExtensionReturnTypeAttribute.cs
- CodeStatement.cs
- ImageFormatConverter.cs
- ActivityCodeDomSerializer.cs
- BindingContext.cs
- ApplicationBuildProvider.cs
- PrivilegedConfigurationManager.cs
- MembershipPasswordException.cs
- LinqDataSourceSelectEventArgs.cs
- LogicalMethodInfo.cs
- OdbcConnectionFactory.cs
- ColorContext.cs
- TimerElapsedEvenArgs.cs