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
- SHA256Managed.cs
- InfoCardRSAOAEPKeyExchangeDeformatter.cs
- InvalidPrinterException.cs
- AttributeTable.cs
- TrackingMemoryStreamFactory.cs
- RuntimeHelpers.cs
- DocumentViewerHelper.cs
- FixedSOMElement.cs
- DesignerTransactionCloseEvent.cs
- HttpRequestBase.cs
- ObjectCloneHelper.cs
- ExecutedRoutedEventArgs.cs
- MsmqProcessProtocolHandler.cs
- connectionpool.cs
- PackWebRequestFactory.cs
- MethodBuilderInstantiation.cs
- LicenseManager.cs
- MatrixStack.cs
- WebBrowserNavigatingEventHandler.cs
- SchemaCreator.cs
- SymmetricCryptoHandle.cs
- OrderedDictionary.cs
- MetadataUtilsSmi.cs
- FilterQuery.cs
- SecurityAccessDeniedException.cs
- TypeDependencyAttribute.cs
- ReadOnlyObservableCollection.cs
- OrderedDictionaryStateHelper.cs
- ThreadStartException.cs
- HttpListener.cs
- Rect.cs
- SerializerDescriptor.cs
- EncryptedData.cs
- LinkArea.cs
- WorkflowApplicationEventArgs.cs
- RuntimeWrappedException.cs
- SafeNativeMethods.cs
- MenuItemCollectionEditorDialog.cs
- AnnotationStore.cs
- ObjectStateFormatter.cs
- TraceLog.cs
- EventMap.cs
- ComContractElementCollection.cs
- XPathItem.cs
- FrameworkElementFactoryMarkupObject.cs
- URLString.cs
- RectangleConverter.cs
- HierarchicalDataBoundControl.cs
- GroupBox.cs
- Storyboard.cs
- SqlRowUpdatedEvent.cs
- MessageContractImporter.cs
- DesignerActionTextItem.cs
- VisualBrush.cs
- counter.cs
- AggregationMinMaxHelpers.cs
- FaultDesigner.cs
- Set.cs
- Expander.cs
- DataGridViewHitTestInfo.cs
- XmlWrappingWriter.cs
- ExceptionUtility.cs
- PersonalizationStateInfo.cs
- XmlSerializationWriter.cs
- path.cs
- StylusPointPropertyInfo.cs
- MSG.cs
- ListSortDescription.cs
- MouseBinding.cs
- Operators.cs
- SecureStringHasher.cs
- TemplateColumn.cs
- RequestCacheManager.cs
- IgnoreSectionHandler.cs
- SmiConnection.cs
- ResXBuildProvider.cs
- mansign.cs
- EdmItemError.cs
- Rfc2898DeriveBytes.cs
- SslStream.cs
- SqlUserDefinedAggregateAttribute.cs
- FolderBrowserDialog.cs
- ComboBoxDesigner.cs
- DoubleCollectionConverter.cs
- LogicalTreeHelper.cs
- WaveHeader.cs
- TdsParserStaticMethods.cs
- ThousandthOfEmRealDoubles.cs
- XmlSubtreeReader.cs
- WinFormsUtils.cs
- Permission.cs
- AuthenticodeSignatureInformation.cs
- PolicyDesigner.cs
- FileDialogPermission.cs
- Vector.cs
- FontUnit.cs
- AndCondition.cs
- InvalidEnumArgumentException.cs
- ShellProvider.cs
- OleDbPropertySetGuid.cs