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
- TakeQueryOptionExpression.cs
- DigestTraceRecordHelper.cs
- SessionStateSection.cs
- ToolStripControlHost.cs
- HostingPreferredMapPath.cs
- Constants.cs
- ColorConverter.cs
- ContextBase.cs
- ExpressionBindingCollection.cs
- PersonalizationProvider.cs
- Transactions.cs
- DataSourceHelper.cs
- OfTypeExpression.cs
- ColorMatrix.cs
- TextServicesHost.cs
- DivideByZeroException.cs
- ComponentChangingEvent.cs
- AsyncDataRequest.cs
- oledbmetadatacollectionnames.cs
- columnmapkeybuilder.cs
- CLSCompliantAttribute.cs
- MissingMemberException.cs
- XmlBinaryReader.cs
- AlgoModule.cs
- HttpListenerContext.cs
- XamlToRtfWriter.cs
- tabpagecollectioneditor.cs
- RangeBase.cs
- ExecutionContext.cs
- ScriptResourceAttribute.cs
- UrlAuthFailedErrorFormatter.cs
- HintTextMaxWidthConverter.cs
- BoundPropertyEntry.cs
- TextServicesContext.cs
- WindowsNonControl.cs
- LocalizabilityAttribute.cs
- RootDesignerSerializerAttribute.cs
- DataGridViewImageCell.cs
- EventListener.cs
- RegexCompilationInfo.cs
- WebEventTraceProvider.cs
- HistoryEventArgs.cs
- StrokeCollection.cs
- LicFileLicenseProvider.cs
- FormsAuthenticationEventArgs.cs
- CommonDialog.cs
- InstancePersistenceException.cs
- WebUtil.cs
- PolicyManager.cs
- FlowDocument.cs
- PropertyPathWorker.cs
- PixelFormat.cs
- MulticastDelegate.cs
- GroupBoxAutomationPeer.cs
- ScaleTransform.cs
- ByteArrayHelperWithString.cs
- XmlTextReader.cs
- Menu.cs
- DetectEofStream.cs
- Configuration.cs
- SafeSecurityHelper.cs
- SecurityElement.cs
- SettingsProviderCollection.cs
- ScrollPattern.cs
- ResourceReferenceExpressionConverter.cs
- BuildProvider.cs
- OleDbException.cs
- __Filters.cs
- SuppressIldasmAttribute.cs
- Light.cs
- WebConfigurationHostFileChange.cs
- ChtmlCalendarAdapter.cs
- FlowLayout.cs
- InputMethodStateChangeEventArgs.cs
- CommonDialog.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- SafeFileMappingHandle.cs
- AppModelKnownContentFactory.cs
- PeerCollaboration.cs
- securestring.cs
- ToolStripGripRenderEventArgs.cs
- VectorAnimationBase.cs
- XmlSchemaInfo.cs
- Size3D.cs
- XmlSchemaSimpleType.cs
- FlowPanelDesigner.cs
- TextShapeableCharacters.cs
- TextTreeNode.cs
- ImageButton.cs
- ObjectReaderCompiler.cs
- AppDomainUnloadedException.cs
- UserPreferenceChangedEventArgs.cs
- OleDbDataReader.cs
- RewritingValidator.cs
- FileAuthorizationModule.cs
- ProcessThread.cs
- MessageQueueInstaller.cs
- StringWriter.cs
- ConfigurationElementCollection.cs
- CollectionChangeEventArgs.cs