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
- ComponentEvent.cs
- RegisteredHiddenField.cs
- SeekableMessageNavigator.cs
- Block.cs
- TableRowCollection.cs
- LinearGradientBrush.cs
- RequiredFieldValidator.cs
- WpfGeneratedKnownProperties.cs
- TypeBuilderInstantiation.cs
- HtmlInputText.cs
- BackStopAuthenticationModule.cs
- SslStream.cs
- ToolStripItemClickedEventArgs.cs
- TransactionProxy.cs
- TransformCollection.cs
- ChtmlTextBoxAdapter.cs
- SystemNetworkInterface.cs
- TraceRecord.cs
- ParserContext.cs
- Parameter.cs
- ObjectDataSourceChooseTypePanel.cs
- CodeIndexerExpression.cs
- TreeWalkHelper.cs
- ModelTreeEnumerator.cs
- FigureParagraph.cs
- XmlTextEncoder.cs
- LambdaExpression.cs
- PropertyPath.cs
- FactoryMaker.cs
- ArrayExtension.cs
- WebServiceEnumData.cs
- CurrencyWrapper.cs
- MSAAWinEventWrap.cs
- DataGridRow.cs
- MarkupCompiler.cs
- ObjectQueryProvider.cs
- MetadataProperty.cs
- EventArgs.cs
- TypeResolver.cs
- CodeTryCatchFinallyStatement.cs
- SelectedDatesCollection.cs
- StateChangeEvent.cs
- EntityReference.cs
- FixedSOMPageElement.cs
- RectangleGeometry.cs
- OrthographicCamera.cs
- SSmlParser.cs
- CodeTypeDeclarationCollection.cs
- KnownTypesProvider.cs
- EntityDataSourceEntityTypeFilterItem.cs
- AVElementHelper.cs
- MinMaxParagraphWidth.cs
- UnmanagedHandle.cs
- SplineKeyFrames.cs
- CodeMethodInvokeExpression.cs
- UriTemplateHelpers.cs
- Validator.cs
- ParagraphResult.cs
- EventBuilder.cs
- AssemblyAttributesGoHere.cs
- CodeMemberField.cs
- DataGridViewHitTestInfo.cs
- _NegotiateClient.cs
- NamespaceEmitter.cs
- XmlElementCollection.cs
- WebServiceReceive.cs
- ScaleTransform3D.cs
- BitmapDecoder.cs
- CheckBoxAutomationPeer.cs
- WindowsFormsLinkLabel.cs
- DataView.cs
- WeakReferenceEnumerator.cs
- TextEditorSpelling.cs
- TableRowGroup.cs
- Vector3DAnimation.cs
- RubberbandSelector.cs
- XmlAttributeOverrides.cs
- LocatorManager.cs
- MemberCollection.cs
- AlignmentXValidation.cs
- ModuleBuilderData.cs
- WindowsNonControl.cs
- OverflowException.cs
- UInt16Converter.cs
- SourceFileBuildProvider.cs
- MsmqIntegrationChannelFactory.cs
- CodeVariableDeclarationStatement.cs
- UserCancellationException.cs
- ProviderCommandInfoUtils.cs
- PackUriHelper.cs
- DataGridTemplateColumn.cs
- SynchronizationLockException.cs
- TextEffect.cs
- TrackingServices.cs
- SoapUnknownHeader.cs
- HitTestParameters.cs
- HMACSHA512.cs
- RepeaterItem.cs
- SqlUserDefinedAggregateAttribute.cs
- EventTrigger.cs