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
- ExternalException.cs
- Variable.cs
- _NtlmClient.cs
- XPathEmptyIterator.cs
- DataMemberConverter.cs
- ActivityInstance.cs
- LoginCancelEventArgs.cs
- PointAnimationClockResource.cs
- LayoutEditorPart.cs
- ResourceExpressionBuilder.cs
- ServicePoint.cs
- TemplateInstanceAttribute.cs
- LayoutTableCell.cs
- QueryTaskGroupState.cs
- CommandDevice.cs
- WebBrowserNavigatedEventHandler.cs
- SQLRoleProvider.cs
- FixedSOMTableRow.cs
- oledbmetadatacollectionnames.cs
- ISSmlParser.cs
- FilteredDataSetHelper.cs
- LeaseManager.cs
- StringComparer.cs
- DataControlFieldHeaderCell.cs
- RowsCopiedEventArgs.cs
- NextPreviousPagerField.cs
- BuilderInfo.cs
- Code.cs
- xamlnodes.cs
- SqlDataSourceSummaryPanel.cs
- StringBuilder.cs
- DesignerVerb.cs
- ReferentialConstraintRoleElement.cs
- ProfileEventArgs.cs
- CaretElement.cs
- TranslateTransform.cs
- LocatorBase.cs
- PagePropertiesChangingEventArgs.cs
- GeometryCollection.cs
- HealthMonitoringSectionHelper.cs
- SettingsContext.cs
- Image.cs
- DebugView.cs
- Command.cs
- RtfControlWordInfo.cs
- File.cs
- SingleTagSectionHandler.cs
- TransformerConfigurationWizardBase.cs
- QueryParameter.cs
- HttpRawResponse.cs
- WmiInstallComponent.cs
- IConvertible.cs
- SecurityIdentifierElementCollection.cs
- SchemaSetCompiler.cs
- IntMinMaxAggregationOperator.cs
- DoubleLinkListEnumerator.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- DateTimePicker.cs
- pingexception.cs
- COM2PictureConverter.cs
- Transform.cs
- SafeUserTokenHandle.cs
- EdmMember.cs
- ArrayItemValue.cs
- CharacterBuffer.cs
- MethodCallConverter.cs
- PackageStore.cs
- WebServicesDescriptionAttribute.cs
- SimpleTypeResolver.cs
- RSAProtectedConfigurationProvider.cs
- SafeThemeHandle.cs
- ReferenceSchema.cs
- CompareInfo.cs
- Size.cs
- TileBrush.cs
- ConstructorExpr.cs
- DataSetUtil.cs
- SynchronizedDispatch.cs
- RectangleF.cs
- Utility.cs
- SqlBulkCopy.cs
- TextEffect.cs
- QilStrConcatenator.cs
- RijndaelManaged.cs
- JavaScriptObjectDeserializer.cs
- GestureRecognitionResult.cs
- ServerIdentity.cs
- SQLInt32.cs
- UIElementParagraph.cs
- FixedSOMTableRow.cs
- ReferencedType.cs
- CodeLinePragma.cs
- ProxyManager.cs
- HttpCapabilitiesSectionHandler.cs
- Assembly.cs
- SafeNativeMemoryHandle.cs
- StrongNameMembershipCondition.cs
- SafePointer.cs
- RightsManagementProvider.cs
- ProjectionPlanCompiler.cs