Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- TextSelectionProcessor.cs
- MappedMetaModel.cs
- XPathNodePointer.cs
- ImportContext.cs
- ProcessThreadCollection.cs
- SafeNativeMethodsMilCoreApi.cs
- BindingContext.cs
- wpf-etw.cs
- MainMenu.cs
- ETagAttribute.cs
- ParserContext.cs
- LinkButton.cs
- EdmComplexTypeAttribute.cs
- LinkLabel.cs
- _AcceptOverlappedAsyncResult.cs
- StandardCommands.cs
- ProviderCommandInfoUtils.cs
- BasicKeyConstraint.cs
- UnsafeNativeMethods.cs
- CompositeCollection.cs
- SqlDependencyListener.cs
- JoinGraph.cs
- NullableDecimalAverageAggregationOperator.cs
- ReadOnlyDictionary.cs
- UnionCodeGroup.cs
- PeerTransportListenAddressValidatorAttribute.cs
- GatewayDefinition.cs
- XamlWriterExtensions.cs
- CommandEventArgs.cs
- HTTPNotFoundHandler.cs
- SQLBinaryStorage.cs
- RoutedEvent.cs
- TypeUtils.cs
- Root.cs
- XmlUrlResolver.cs
- TextOnlyOutput.cs
- Point.cs
- StateInitializationDesigner.cs
- RelatedCurrencyManager.cs
- SvcMapFileLoader.cs
- Transform3DCollection.cs
- RegisteredScript.cs
- Parsers.cs
- ProfileEventArgs.cs
- ZoneMembershipCondition.cs
- HttpHostedTransportConfiguration.cs
- FlatButtonAppearance.cs
- ADConnectionHelper.cs
- Permission.cs
- ListViewContainer.cs
- TextRange.cs
- Queue.cs
- EditorBrowsableAttribute.cs
- ProtocolsConfiguration.cs
- Form.cs
- DataObjectMethodAttribute.cs
- counter.cs
- DbParameterCollectionHelper.cs
- TreeViewTemplateSelector.cs
- ColumnMapVisitor.cs
- ConstrainedDataObject.cs
- ListViewGroupConverter.cs
- ExpressionVisitorHelpers.cs
- ManagementClass.cs
- Model3DGroup.cs
- ExpressionBuilder.cs
- DateTimeStorage.cs
- EndpointAddressMessageFilterTable.cs
- CustomWebEventKey.cs
- SqlNamer.cs
- RTLAwareMessageBox.cs
- TerminateDesigner.cs
- RectAnimationClockResource.cs
- PriorityBinding.cs
- EnumerableRowCollection.cs
- ChangeTracker.cs
- TabPage.cs
- DataGridViewHitTestInfo.cs
- DataQuery.cs
- CompilerLocalReference.cs
- OracleConnectionStringBuilder.cs
- WebPartCatalogCloseVerb.cs
- SqlFunctionAttribute.cs
- XmlImplementation.cs
- LayoutEngine.cs
- TouchFrameEventArgs.cs
- RegexRunner.cs
- CaseInsensitiveComparer.cs
- XXXOnTypeBuilderInstantiation.cs
- AppSettingsReader.cs
- GenericIdentity.cs
- BuildProvider.cs
- DocumentSequenceHighlightLayer.cs
- UidManager.cs
- AlternationConverter.cs
- HttpInputStream.cs
- TypeConverter.cs
- BinHexEncoding.cs
- XmlLanguageConverter.cs
- SymmetricAlgorithm.cs