Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Base / MS / Internal / Markup / TypeConverterValueSerializer.cs / 2 / 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, System.Windows.Markup.TypeConverterHelper.EnglishUSCulture, value);
}
public override bool CanConvertFromString(string value, IValueSerializerContext context)
{
return true;
}
public override object ConvertFromString(string value, IValueSerializerContext context)
{
return converter.ConvertFrom(context, System.Windows.Markup.TypeConverterHelper.EnglishUSCulture, 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, System.Windows.Markup.TypeConverterHelper.EnglishUSCulture, value);
}
public override bool CanConvertFromString(string value, IValueSerializerContext context)
{
return true;
}
public override object ConvertFromString(string value, IValueSerializerContext context)
{
return converter.ConvertFrom(context, System.Windows.Markup.TypeConverterHelper.EnglishUSCulture, 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
- PartitionedStream.cs
- WaitHandleCannotBeOpenedException.cs
- SpellerHighlightLayer.cs
- FrameworkElementAutomationPeer.cs
- SHA256Managed.cs
- ResourceReferenceExpressionConverter.cs
- DataSourceControl.cs
- BrushProxy.cs
- ToolboxComponentsCreatedEventArgs.cs
- ConfigurationStrings.cs
- XmlSerializerAssemblyAttribute.cs
- ListenerTraceUtility.cs
- SystemIPAddressInformation.cs
- CollectionMarkupSerializer.cs
- DirectoryInfo.cs
- HelpInfo.cs
- ReliableSessionBindingElementImporter.cs
- SecurityRuntime.cs
- WpfPayload.cs
- WhitespaceSignificantCollectionAttribute.cs
- QilLiteral.cs
- StaticSiteMapProvider.cs
- SectionInformation.cs
- ConfigurationLocationCollection.cs
- ModuleConfigurationInfo.cs
- OracleParameterCollection.cs
- Journaling.cs
- SignatureResourcePool.cs
- XsltException.cs
- CaseDesigner.xaml.cs
- NegotiationTokenAuthenticatorStateCache.cs
- ErrorHandlingAcceptor.cs
- CheckBoxAutomationPeer.cs
- PoisonMessageException.cs
- ThemeInfoAttribute.cs
- ConfigurationManagerInternal.cs
- X509ChainElement.cs
- Util.cs
- WindowsProgressbar.cs
- PerformanceCountersElement.cs
- RequestCacheManager.cs
- HttpException.cs
- KerberosSecurityTokenAuthenticator.cs
- JavaScriptObjectDeserializer.cs
- XmlSchemaGroup.cs
- UIInitializationException.cs
- ITextView.cs
- Roles.cs
- OdbcStatementHandle.cs
- HttpCachePolicy.cs
- Line.cs
- XmlSortKeyAccumulator.cs
- PasswordDeriveBytes.cs
- FileSystemEventArgs.cs
- TypeLibConverter.cs
- RemoteWebConfigurationHostServer.cs
- safemediahandle.cs
- GlyphCollection.cs
- TextDecorationUnitValidation.cs
- TextEffectCollection.cs
- EFDataModelProvider.cs
- WebConfigurationManager.cs
- Comparer.cs
- GenericTypeParameterConverter.cs
- WmlCalendarAdapter.cs
- MailAddressCollection.cs
- ScrollViewerAutomationPeer.cs
- OleDbPropertySetGuid.cs
- Volatile.cs
- DataGridViewCellFormattingEventArgs.cs
- HashUtility.cs
- Missing.cs
- DecoratedNameAttribute.cs
- assemblycache.cs
- ACL.cs
- DeadCharTextComposition.cs
- TagPrefixInfo.cs
- PassportIdentity.cs
- ImageCodecInfoPrivate.cs
- CodeTypeParameterCollection.cs
- WorkflowElementDialog.cs
- ExtentCqlBlock.cs
- Event.cs
- SystemIcmpV4Statistics.cs
- DropDownList.cs
- ExceptionUtility.cs
- ExpressionCopier.cs
- ExceptionNotification.cs
- TextLine.cs
- SapiGrammar.cs
- Context.cs
- AmbientLight.cs
- DependencyProperty.cs
- SyndicationSerializer.cs
- StrokeNodeOperations2.cs
- VariantWrapper.cs
- FilteredReadOnlyMetadataCollection.cs
- SemaphoreFullException.cs
- XmlParserContext.cs
- MustUnderstandBehavior.cs