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
- DataMemberListEditor.cs
- BaseResourcesBuildProvider.cs
- TypeConverterHelper.cs
- XamlTemplateSerializer.cs
- ArrayExtension.cs
- SignatureResourceHelper.cs
- UnsafeNativeMethodsPenimc.cs
- AsymmetricSignatureFormatter.cs
- DatasetMethodGenerator.cs
- configsystem.cs
- QueryParameter.cs
- BrowserDefinitionCollection.cs
- ProfessionalColors.cs
- MultilineStringConverter.cs
- WindowsStatic.cs
- ConfigurationManagerInternalFactory.cs
- SettingsContext.cs
- ObjectDisposedException.cs
- NavigationHelper.cs
- SimpleFieldTemplateFactory.cs
- OutOfProcStateClientManager.cs
- SamlAuthorizationDecisionClaimResource.cs
- WebPartConnectionCollection.cs
- Size3DConverter.cs
- ChannelManager.cs
- AuthenticateEventArgs.cs
- SafePipeHandle.cs
- PageEventArgs.cs
- _HTTPDateParse.cs
- CommandValueSerializer.cs
- FormsAuthenticationUserCollection.cs
- ApplicationFileCodeDomTreeGenerator.cs
- CircleHotSpot.cs
- XmlCDATASection.cs
- InsufficientMemoryException.cs
- CheckBoxPopupAdapter.cs
- DesignTable.cs
- NetTcpSectionData.cs
- UpdateTracker.cs
- MailWriter.cs
- ToolStripOverflow.cs
- XPathParser.cs
- NameValueCollection.cs
- SqlNodeAnnotation.cs
- RequestSecurityTokenResponse.cs
- AttachedAnnotationChangedEventArgs.cs
- FormViewDeletedEventArgs.cs
- AutoResetEvent.cs
- NavigationService.cs
- UdpDuplexChannel.cs
- DrawListViewSubItemEventArgs.cs
- DefaultParameterValueAttribute.cs
- DBPropSet.cs
- CompilerInfo.cs
- NetworkStream.cs
- ThumbButtonInfo.cs
- Lease.cs
- ImageBrush.cs
- ShaderRenderModeValidation.cs
- Attributes.cs
- SerializationFieldInfo.cs
- PackageProperties.cs
- TextBoxRenderer.cs
- BreadCrumbTextConverter.cs
- FontConverter.cs
- Point3DCollectionConverter.cs
- CharacterMetrics.cs
- TagNameToTypeMapper.cs
- WorkItem.cs
- ManagementEventArgs.cs
- HScrollBar.cs
- SQLBoolean.cs
- TextEditorSpelling.cs
- FilterElement.cs
- ProcessModuleDesigner.cs
- SoapFault.cs
- RouteData.cs
- HttpInputStream.cs
- FixUpCollection.cs
- NonVisualControlAttribute.cs
- WebPartDeleteVerb.cs
- ReliableChannelFactory.cs
- ProviderConnectionPoint.cs
- DataRecordInternal.cs
- DesignerOptionService.cs
- Math.cs
- GlobalEventManager.cs
- FocusManager.cs
- COM2PropertyDescriptor.cs
- FlowDocumentView.cs
- CalendarModeChangedEventArgs.cs
- BasicViewGenerator.cs
- ControlAdapter.cs
- TimeStampChecker.cs
- CharacterMetrics.cs
- EventRecordWrittenEventArgs.cs
- handlecollector.cs
- DictionaryEditChange.cs
- PeerPresenceInfo.cs
- TextRangeAdaptor.cs