Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- TypeHelpers.cs
- SecondaryViewProvider.cs
- fixedPageContentExtractor.cs
- FillRuleValidation.cs
- OutOfProcStateClientManager.cs
- DetailsViewDesigner.cs
- XmlAttributeOverrides.cs
- InstanceView.cs
- Assert.cs
- DeleteStoreRequest.cs
- OrderByQueryOptionExpression.cs
- Effect.cs
- XPathSelfQuery.cs
- HwndProxyElementProvider.cs
- SplitterCancelEvent.cs
- FileDetails.cs
- FixUp.cs
- DeviceFilterDictionary.cs
- SubqueryRules.cs
- translator.cs
- GuidelineSet.cs
- XmlSchemaExporter.cs
- XmlWriterDelegator.cs
- EmptyReadOnlyDictionaryInternal.cs
- SafePointer.cs
- BlockCollection.cs
- RoutedCommand.cs
- BuildManagerHost.cs
- IsolatedStoragePermission.cs
- SQLChars.cs
- VisualBasicExpressionConverter.cs
- EntityDataSourceChangingEventArgs.cs
- IntPtr.cs
- SessionKeyExpiredException.cs
- GrammarBuilderWildcard.cs
- ListComponentEditorPage.cs
- KoreanCalendar.cs
- LineGeometry.cs
- SupportsEventValidationAttribute.cs
- NavigationWindowAutomationPeer.cs
- URL.cs
- KeyValueInternalCollection.cs
- CodeTypeMemberCollection.cs
- PrintPreviewControl.cs
- EmptyElement.cs
- CodeTypeOfExpression.cs
- LoadWorkflowByKeyAsyncResult.cs
- InstancePersistenceEvent.cs
- SymbolPair.cs
- CompiledQueryCacheKey.cs
- DataBinding.cs
- ButtonBaseDesigner.cs
- FixedSOMTextRun.cs
- DataPointer.cs
- ReadOnlyAttribute.cs
- ListViewInsertEventArgs.cs
- SamlSubjectStatement.cs
- Sequence.cs
- Nullable.cs
- ClientConfigurationHost.cs
- SerializationObjectManager.cs
- AuthStoreRoleProvider.cs
- DataGridCellsPanel.cs
- OpenTypeLayout.cs
- WinFormsComponentEditor.cs
- TransformGroup.cs
- ObjectDisposedException.cs
- ProviderException.cs
- SqlDelegatedTransaction.cs
- ClientRuntimeConfig.cs
- TypeDescriptionProvider.cs
- SqlProvider.cs
- GuidConverter.cs
- DropTarget.cs
- ParentControlDesigner.cs
- MaskedTextProvider.cs
- FrameAutomationPeer.cs
- CultureInfoConverter.cs
- COM2PropertyDescriptor.cs
- DataControlLinkButton.cs
- GroupDescription.cs
- RadioButtonRenderer.cs
- MulticastNotSupportedException.cs
- ExternalException.cs
- StatusStrip.cs
- GrabHandleGlyph.cs
- ApplicationSettingsBase.cs
- AssemblyHash.cs
- QueryExtender.cs
- ImageSource.cs
- AddInSegmentDirectoryNotFoundException.cs
- AssemblyBuilder.cs
- PrintDialogException.cs
- DeleteMemberBinder.cs
- BaseDataListDesigner.cs
- ProfilePropertyNameValidator.cs
- DecoderExceptionFallback.cs
- SendKeys.cs
- NavigationProperty.cs
- VariantWrapper.cs