Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Base / MS / Internal / Markup / TypeConverterValueSerializer.cs / 1 / TypeConverterValueSerializer.cs
//------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: TypeConverterValueSerializer.cs // // Contents: TypeConverter to ValueSerializer adapter // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System.ComponentModel; using System.Globalization; using System.Windows.Markup; namespace MS.Internal.Serialization { ////// The TypeConverter value serializer uses a TypeConverter to implement the translation /// to and from a string. The caller of the constructor must ensure the TypeConverter supports /// converstion to and from string. /// internal sealed class TypeConverterValueSerializer : ValueSerializer { private TypeConverter converter; public TypeConverterValueSerializer(TypeConverter converter) { this.converter = converter; } public override bool CanConvertToString(object value, IValueSerializerContext context) { return converter.CanConvertTo(context, typeof(string)); } public override string ConvertToString(object value, IValueSerializerContext context) { return converter.ConvertToString(context, CultureInfo.GetCultureInfo("en-us"), value); } public override bool CanConvertFromString(string value, IValueSerializerContext context) { return true; } public override object ConvertFromString(string value, IValueSerializerContext context) { return converter.ConvertFrom(context, CultureInfo.GetCultureInfo("en-us"), value); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: TypeConverterValueSerializer.cs // // Contents: TypeConverter to ValueSerializer adapter // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System.ComponentModel; using System.Globalization; using System.Windows.Markup; namespace MS.Internal.Serialization { ////// The TypeConverter value serializer uses a TypeConverter to implement the translation /// to and from a string. The caller of the constructor must ensure the TypeConverter supports /// converstion to and from string. /// internal sealed class TypeConverterValueSerializer : ValueSerializer { private TypeConverter converter; public TypeConverterValueSerializer(TypeConverter converter) { this.converter = converter; } public override bool CanConvertToString(object value, IValueSerializerContext context) { return converter.CanConvertTo(context, typeof(string)); } public override string ConvertToString(object value, IValueSerializerContext context) { return converter.ConvertToString(context, CultureInfo.GetCultureInfo("en-us"), value); } public override bool CanConvertFromString(string value, IValueSerializerContext context) { return true; } public override object ConvertFromString(string value, IValueSerializerContext context) { return converter.ConvertFrom(context, CultureInfo.GetCultureInfo("en-us"), value); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BamlLocalizationDictionary.cs
- InnerItemCollectionView.cs
- WindowInteropHelper.cs
- GradientSpreadMethodValidation.cs
- DbParameterCollection.cs
- InvalidCommandTreeException.cs
- sqlinternaltransaction.cs
- SqlDataSourceFilteringEventArgs.cs
- Bold.cs
- InputReport.cs
- SqlHelper.cs
- ToolStripPanelRenderEventArgs.cs
- XmlSchemaInferenceException.cs
- DataGridViewRowCancelEventArgs.cs
- MatrixAnimationBase.cs
- ProfilePropertySettings.cs
- CollectionViewGroup.cs
- DtdParser.cs
- TcpSocketManager.cs
- SettingsPropertyValueCollection.cs
- OpCodes.cs
- TextProperties.cs
- PathStreamGeometryContext.cs
- BlurEffect.cs
- VirtualizingStackPanel.cs
- AuthenticateEventArgs.cs
- Baml6ConstructorInfo.cs
- PropertyContainer.cs
- webeventbuffer.cs
- WindowsAuthenticationEventArgs.cs
- MarshalDirectiveException.cs
- DesignBindingValueUIHandler.cs
- SqlInternalConnectionTds.cs
- FtpCachePolicyElement.cs
- MaskedTextBoxTextEditor.cs
- ClientScriptManagerWrapper.cs
- ArrayWithOffset.cs
- EntityDataSourceValidationException.cs
- PropertyDescriptorComparer.cs
- XmlRawWriter.cs
- ImpersonationContext.cs
- TextEffect.cs
- ToolBarOverflowPanel.cs
- IODescriptionAttribute.cs
- ArrayConverter.cs
- SqlGenerator.cs
- FileSystemInfo.cs
- DataGridViewRowCollection.cs
- HttpDebugHandler.cs
- Icon.cs
- MemberAccessException.cs
- DetailsViewInsertedEventArgs.cs
- KnownColorTable.cs
- Column.cs
- Comparer.cs
- SecurityTokenProviderContainer.cs
- TransformCryptoHandle.cs
- UserControlBuildProvider.cs
- BuildProvider.cs
- WebBaseEventKeyComparer.cs
- ToolStripStatusLabel.cs
- TextRangeEdit.cs
- AssociationSetEnd.cs
- HierarchicalDataSourceControl.cs
- NullableLongAverageAggregationOperator.cs
- _HeaderInfo.cs
- ItemCheckedEvent.cs
- ServiceReference.cs
- SystemResourceKey.cs
- TimeSpanMinutesConverter.cs
- StdRegProviderWrapper.cs
- TextElement.cs
- QuotedPrintableStream.cs
- ContractTypeNameElement.cs
- FeatureSupport.cs
- TrackingServices.cs
- CreateUserWizardStep.cs
- EmbeddedObject.cs
- TopClause.cs
- CornerRadiusConverter.cs
- DbProviderFactory.cs
- CodeTypeMember.cs
- DecimalAnimation.cs
- SchemaContext.cs
- WorkflowApplicationCompletedException.cs
- Directory.cs
- CheckBoxBaseAdapter.cs
- RegexFCD.cs
- Keywords.cs
- HasCopySemanticsAttribute.cs
- ExpandedWrapper.cs
- SqlServices.cs
- SiteMapSection.cs
- HttpClientCertificate.cs
- ListViewInsertionMark.cs
- PropertyGridEditorPart.cs
- DataGridViewHeaderCell.cs
- ToolStripItemCollection.cs
- LogEntrySerializationException.cs
- DesignerForm.cs