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
- TypeSource.cs
- Visitor.cs
- ToolboxCategoryItems.cs
- OutputScopeManager.cs
- BindableAttribute.cs
- XmlLanguage.cs
- ContentElementAutomationPeer.cs
- SQLInt32.cs
- OutputScopeManager.cs
- BrowserDefinition.cs
- UdpChannelFactory.cs
- ColumnMapTranslator.cs
- PublishLicense.cs
- XmlTypeMapping.cs
- Token.cs
- QueryGeneratorBase.cs
- FixedSOMTextRun.cs
- Logging.cs
- PrincipalPermission.cs
- OpenTypeLayout.cs
- ListBoxDesigner.cs
- XmlSchema.cs
- AuthenticateEventArgs.cs
- Annotation.cs
- ArraySegment.cs
- RichTextBoxConstants.cs
- UInt64Converter.cs
- DefaultObjectSerializer.cs
- JournalEntry.cs
- StylusCollection.cs
- PeerPresenceInfo.cs
- SqlTriggerContext.cs
- SafeBitVector32.cs
- BindingManagerDataErrorEventArgs.cs
- CommandManager.cs
- SchemaNotation.cs
- TargetControlTypeCache.cs
- DesignerActionTextItem.cs
- ResourceDictionary.cs
- WmlObjectListAdapter.cs
- BuildProviderUtils.cs
- ConsoleCancelEventArgs.cs
- clipboard.cs
- TextServicesCompartmentContext.cs
- HtmlFormWrapper.cs
- ComboBoxAutomationPeer.cs
- SimpleApplicationHost.cs
- cookiecontainer.cs
- Annotation.cs
- SplitterPanel.cs
- OdbcInfoMessageEvent.cs
- SessionStateSection.cs
- AssociationEndMember.cs
- UnmanagedMemoryStreamWrapper.cs
- VisualStyleTypesAndProperties.cs
- MessageDecoder.cs
- BitmapImage.cs
- PopupRoot.cs
- AppDomainAttributes.cs
- ToolStripProgressBar.cs
- FontConverter.cs
- GenericEnumConverter.cs
- EntityContainerRelationshipSetEnd.cs
- BinaryParser.cs
- SafeRightsManagementSessionHandle.cs
- TextElement.cs
- OwnerDrawPropertyBag.cs
- Rectangle.cs
- WebHttpSecurity.cs
- FontUnit.cs
- QuerySettings.cs
- Stylesheet.cs
- SerializerProvider.cs
- PointKeyFrameCollection.cs
- VerificationAttribute.cs
- Brush.cs
- HitTestResult.cs
- Part.cs
- ReliableSession.cs
- DuplicateWaitObjectException.cs
- ZoneButton.cs
- FileSystemWatcher.cs
- OpenFileDialog.cs
- AnnotationResource.cs
- DES.cs
- SchemaNames.cs
- GuidConverter.cs
- WsdlImporterElement.cs
- QuaternionKeyFrameCollection.cs
- GeometryCombineModeValidation.cs
- Label.cs
- ImageKeyConverter.cs
- EmptyArray.cs
- ConfigurationProperty.cs
- PersonalizationAdministration.cs
- PerformanceCounterTraceRecord.cs
- EmptyCollection.cs
- DbConnectionPoolCounters.cs
- FlowDocumentReaderAutomationPeer.cs
- TemplateManager.cs