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
- DurableErrorHandler.cs
- RoutedPropertyChangedEventArgs.cs
- Int32Rect.cs
- SimpleMailWebEventProvider.cs
- HttpConfigurationSystem.cs
- RSACryptoServiceProvider.cs
- WindowAutomationPeer.cs
- TextOnlyOutput.cs
- ValidationSummary.cs
- PingReply.cs
- PlatformNotSupportedException.cs
- RowUpdatedEventArgs.cs
- HMACMD5.cs
- ListItemParagraph.cs
- BufferedStream.cs
- PresentationSource.cs
- RegisteredHiddenField.cs
- TdsParserStateObject.cs
- WindowsScroll.cs
- HasCopySemanticsAttribute.cs
- IFlowDocumentViewer.cs
- DependencyProperty.cs
- UnsafeNativeMethodsMilCoreApi.cs
- ApplicationFileParser.cs
- WsdlInspector.cs
- Options.cs
- EntityDataSourceDesignerHelper.cs
- DeflateEmulationStream.cs
- StylusButtonEventArgs.cs
- AttributeAction.cs
- CrossSiteScriptingValidation.cs
- Component.cs
- IfAction.cs
- CachedBitmap.cs
- UIElementCollection.cs
- CanonicalFontFamilyReference.cs
- DesignSurfaceCollection.cs
- PasswordTextContainer.cs
- Profiler.cs
- BaseParaClient.cs
- Parameter.cs
- GPRECTF.cs
- BuildManagerHost.cs
- QilLoop.cs
- RegistryKey.cs
- ImportedNamespaceContextItem.cs
- KoreanLunisolarCalendar.cs
- InvokePatternIdentifiers.cs
- CodeVariableReferenceExpression.cs
- LogLogRecordHeader.cs
- SerializationInfoEnumerator.cs
- NumberFunctions.cs
- HtmlAnchor.cs
- DataList.cs
- HashJoinQueryOperatorEnumerator.cs
- DataListItemCollection.cs
- ClassicBorderDecorator.cs
- brushes.cs
- XmlConvert.cs
- ScopelessEnumAttribute.cs
- DataServiceException.cs
- DataPointer.cs
- ElementAtQueryOperator.cs
- DefaultMemberAttribute.cs
- ToolTipService.cs
- Stream.cs
- XMLUtil.cs
- SafeCertificateStore.cs
- RichTextBoxAutomationPeer.cs
- connectionpool.cs
- InvalidAsynchronousStateException.cs
- ReliableChannelListener.cs
- PageAsyncTask.cs
- HttpListener.cs
- CultureData.cs
- LingerOption.cs
- DashStyle.cs
- DeclaredTypeValidator.cs
- HttpCachePolicyElement.cs
- Viewport3DAutomationPeer.cs
- XamlSerializerUtil.cs
- ToolStripContainer.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- PriorityChain.cs
- ExportOptions.cs
- SoapSchemaMember.cs
- DbConnectionHelper.cs
- NavigatorInput.cs
- ZipFileInfoCollection.cs
- ACE.cs
- ProcessHostConfigUtils.cs
- SpeechRecognizer.cs
- Schema.cs
- FirstQueryOperator.cs
- ListViewSortEventArgs.cs
- JsonObjectDataContract.cs
- WinEventTracker.cs
- ServiceDescriptions.cs
- SecurityException.cs
- Win32NamedPipes.cs