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
- GridViewCancelEditEventArgs.cs
- DataGridViewComboBoxColumnDesigner.cs
- InputLanguageManager.cs
- NumberFormatInfo.cs
- LinqDataSourceDisposeEventArgs.cs
- FontDialog.cs
- ActiveXHost.cs
- SchemaNotation.cs
- UTF32Encoding.cs
- FirewallWrapper.cs
- XmlHierarchicalDataSourceView.cs
- DispatchChannelSink.cs
- Codec.cs
- Types.cs
- ButtonDesigner.cs
- OdbcHandle.cs
- PrePrepareMethodAttribute.cs
- WindowProviderWrapper.cs
- ObjectStateManagerMetadata.cs
- XmlBoundElement.cs
- ExpressionVisitor.cs
- EntryPointNotFoundException.cs
- cookiecontainer.cs
- EnumBuilder.cs
- DataGridViewSelectedCellCollection.cs
- ComboBoxItem.cs
- Bind.cs
- SqlDataSourceView.cs
- RenamedEventArgs.cs
- SamlNameIdentifierClaimResource.cs
- ToolStripItem.cs
- bindurihelper.cs
- _emptywebproxy.cs
- EpmHelper.cs
- LifetimeServices.cs
- PerformanceCounterPermissionEntry.cs
- SyntaxCheck.cs
- ArraySortHelper.cs
- SqlRowUpdatingEvent.cs
- AuthenticationModuleElement.cs
- WebServiceEnumData.cs
- ReadOnlyMetadataCollection.cs
- NotSupportedException.cs
- RenderData.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- ListDictionary.cs
- RestClientProxyHandler.cs
- RichTextBox.cs
- IssuanceLicense.cs
- HMACSHA256.cs
- PeerNameResolver.cs
- FileUtil.cs
- TextViewDesigner.cs
- ImageSourceValueSerializer.cs
- Empty.cs
- DbMetaDataColumnNames.cs
- TextElementEditingBehaviorAttribute.cs
- TableLayoutPanelResizeGlyph.cs
- DbConnectionInternal.cs
- TableLayoutStyle.cs
- WindowsStatic.cs
- ResXFileRef.cs
- PartialList.cs
- ListViewItem.cs
- NullRuntimeConfig.cs
- Itemizer.cs
- StrokeNodeOperations2.cs
- ColumnResult.cs
- ThicknessConverter.cs
- DrawingContextWalker.cs
- Win32PrintDialog.cs
- CorruptStoreException.cs
- PropertyDescriptorCollection.cs
- UnsafeNetInfoNativeMethods.cs
- PeerInvitationResponse.cs
- TypeDependencyAttribute.cs
- Matrix3D.cs
- StorageComplexTypeMapping.cs
- followingsibling.cs
- ToolTip.cs
- ServiceModelSecurityTokenTypes.cs
- TextServicesDisplayAttributePropertyRanges.cs
- WindowsTreeView.cs
- XPathSingletonIterator.cs
- ImageCodecInfoPrivate.cs
- XmlSecureResolver.cs
- DetailsViewPageEventArgs.cs
- ExpressionBinding.cs
- DataObjectPastingEventArgs.cs
- SchemaImporter.cs
- TransformerTypeCollection.cs
- AssemblyInfo.cs
- ControlBindingsCollection.cs
- Win32PrintDialog.cs
- OperationParameterInfoCollection.cs
- WeakHashtable.cs
- CultureInfoConverter.cs
- ControlAdapter.cs
- Ppl.cs
- DataGridViewDataErrorEventArgs.cs