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
- HMACMD5.cs
- ActivationArguments.cs
- AnimationClock.cs
- IPAddress.cs
- RightNameExpirationInfoPair.cs
- SqlProviderServices.cs
- ConfigurationManagerInternalFactory.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- VirtualPath.cs
- InputBuffer.cs
- ClientRuntimeConfig.cs
- MexHttpBindingElement.cs
- SymbolMethod.cs
- invalidudtexception.cs
- odbcmetadatafactory.cs
- WebEvents.cs
- SchemaConstraints.cs
- SoapAttributeOverrides.cs
- LookupTables.cs
- ScrollBar.cs
- TagPrefixAttribute.cs
- ScriptServiceAttribute.cs
- Schema.cs
- ProtocolElement.cs
- AudioFormatConverter.cs
- DecimalAverageAggregationOperator.cs
- AuthorizationBehavior.cs
- IncomingWebRequestContext.cs
- EventLogLink.cs
- MachineKeySection.cs
- ProcessThreadCollection.cs
- EntityDataSourceWrapperCollection.cs
- GacUtil.cs
- MenuItemBinding.cs
- WebServiceEndpoint.cs
- ShaperBuffers.cs
- Model3DGroup.cs
- ObjectAnimationUsingKeyFrames.cs
- VisualBrush.cs
- TableLayoutSettings.cs
- PackWebRequest.cs
- MediaScriptCommandRoutedEventArgs.cs
- MetadataPropertyCollection.cs
- SourceInterpreter.cs
- TreeView.cs
- VirtualPathExtension.cs
- FragmentNavigationEventArgs.cs
- RadioButton.cs
- LoadWorkflowCommand.cs
- ObjectResult.cs
- DrawingAttributeSerializer.cs
- Int32CollectionConverter.cs
- Metafile.cs
- TextEditorContextMenu.cs
- CodeTypeMember.cs
- IdentifierCreationService.cs
- WinEventTracker.cs
- BmpBitmapDecoder.cs
- SqlXml.cs
- LabelExpression.cs
- SpellCheck.cs
- DataReceivedEventArgs.cs
- ReaderWriterLock.cs
- DecoderFallbackWithFailureFlag.cs
- TypeConstant.cs
- AndCondition.cs
- BuildProviderUtils.cs
- CodeTypeDelegate.cs
- InvokePattern.cs
- ClientSponsor.cs
- WebResourceUtil.cs
- Triangle.cs
- RtfToXamlLexer.cs
- NativeWindow.cs
- InputLanguage.cs
- ByValueEqualityComparer.cs
- XmlDictionary.cs
- MobileControlDesigner.cs
- ExtensionSimplifierMarkupObject.cs
- DataTrigger.cs
- PropertyGeneratedEventArgs.cs
- FlowDocumentPage.cs
- VerticalAlignConverter.cs
- DecoderExceptionFallback.cs
- CustomPopupPlacement.cs
- XPathException.cs
- SchemaImporterExtension.cs
- UIntPtr.cs
- CalendarDateRangeChangingEventArgs.cs
- StateManagedCollection.cs
- TypeSystem.cs
- CommonDialog.cs
- HttpResponse.cs
- ToolboxItemFilterAttribute.cs
- MultiAsyncResult.cs
- CodeStatementCollection.cs
- InkCanvasSelectionAdorner.cs
- cache.cs
- WindowsHyperlink.cs
- webbrowsersite.cs