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
- OptimizerPatterns.cs
- FunctionQuery.cs
- ValidationHelpers.cs
- SerialPinChanges.cs
- IncrementalCompileAnalyzer.cs
- XmlConvert.cs
- EtwTrace.cs
- OwnerDrawPropertyBag.cs
- DiscoveryExceptionDictionary.cs
- BinaryUtilClasses.cs
- FontWeight.cs
- RoutedEventValueSerializer.cs
- BuildProviderAppliesToAttribute.cs
- InvalidPrinterException.cs
- RegistrySecurity.cs
- TextDecorationLocationValidation.cs
- XmlUrlResolver.cs
- CollectionViewGroupInternal.cs
- CompiledAction.cs
- SignatureResourceHelper.cs
- MembershipPasswordException.cs
- IListConverters.cs
- XmlSchemaAny.cs
- ProfileManager.cs
- RawTextInputReport.cs
- DoubleCollection.cs
- CollectionExtensions.cs
- DBConnectionString.cs
- Win32Native.cs
- SmiEventSink_DeferedProcessing.cs
- ValidationPropertyAttribute.cs
- InfiniteTimeSpanConverter.cs
- ToolStripCollectionEditor.cs
- WebBrowserBase.cs
- DecoderExceptionFallback.cs
- SqlClientWrapperSmiStreamChars.cs
- FieldBuilder.cs
- PermissionSetEnumerator.cs
- TableParaClient.cs
- XsdValidatingReader.cs
- ArrayList.cs
- SmuggledIUnknown.cs
- NameTable.cs
- UniqueIdentifierService.cs
- LightweightEntityWrapper.cs
- TaskFormBase.cs
- CompilerGlobalScopeAttribute.cs
- SettingsProperty.cs
- ParallelQuery.cs
- DescendantQuery.cs
- MeasureData.cs
- InputLanguageCollection.cs
- FactoryId.cs
- SQLBytesStorage.cs
- ActivityInstanceMap.cs
- DataGridViewRowPostPaintEventArgs.cs
- MostlySingletonList.cs
- ActivityValidator.cs
- BinaryMethodMessage.cs
- TreeNodeStyle.cs
- GetWinFXPath.cs
- PageContent.cs
- BulletedListDesigner.cs
- PropertyChangedEventManager.cs
- String.cs
- DecoderBestFitFallback.cs
- PermissionSet.cs
- SurrogateDataContract.cs
- SyntaxCheck.cs
- ArcSegment.cs
- DoubleKeyFrameCollection.cs
- Popup.cs
- PublisherIdentityPermission.cs
- RemoteAsymmetricSignatureFormatter.cs
- DataSourceSelectArguments.cs
- WaitForChangedResult.cs
- CompilationAssemblyInstallComponent.cs
- DataGridViewCellValidatingEventArgs.cs
- VisualTarget.cs
- SystemColors.cs
- HttpVersion.cs
- XmlnsCompatibleWithAttribute.cs
- SHA384.cs
- KeyboardDevice.cs
- WorkflowEnvironment.cs
- QueryOptionExpression.cs
- TokenBasedSetEnumerator.cs
- WorkflowInstance.cs
- AsymmetricKeyExchangeFormatter.cs
- OpenFileDialog.cs
- DataSet.cs
- ProfileInfo.cs
- WebPartCloseVerb.cs
- DataGridTextBoxColumn.cs
- TreeViewBindingsEditor.cs
- PauseStoryboard.cs
- SoapIgnoreAttribute.cs
- TabOrder.cs
- SymmetricAlgorithm.cs
- ReflectionUtil.cs