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
- NullableDoubleAverageAggregationOperator.cs
- ClientSideProviderDescription.cs
- ParserStreamGeometryContext.cs
- PeerNeighborManager.cs
- BitmapFrameDecode.cs
- DataControlFieldCollection.cs
- PageBreakRecord.cs
- AttributeData.cs
- ContourSegment.cs
- WebDisplayNameAttribute.cs
- WebPartTransformer.cs
- EntityDataSourceDesigner.cs
- CompositeControl.cs
- UIPermission.cs
- ConfigurationElement.cs
- SyntaxCheck.cs
- ResetableIterator.cs
- PageResolution.cs
- Italic.cs
- CachedPathData.cs
- ApplicationProxyInternal.cs
- Point4DConverter.cs
- LocalizableAttribute.cs
- PageRouteHandler.cs
- WorkflowMarkupElementEventArgs.cs
- SqlFlattener.cs
- BaseParser.cs
- SystemIPAddressInformation.cs
- WebEventCodes.cs
- DetailsViewPagerRow.cs
- CodeAttributeArgument.cs
- BinaryMessageFormatter.cs
- UpdateExpressionVisitor.cs
- ScrollableControl.cs
- GatewayDefinition.cs
- AutoGeneratedFieldProperties.cs
- EntitySqlQueryBuilder.cs
- StructuredTypeEmitter.cs
- ToolStripLocationCancelEventArgs.cs
- PlatformNotSupportedException.cs
- LassoHelper.cs
- KnownAssembliesSet.cs
- ColorTransform.cs
- XmlQueryCardinality.cs
- SemanticResultKey.cs
- RequestQueryProcessor.cs
- UnionQueryOperator.cs
- SemanticResultKey.cs
- SystemWebCachingSectionGroup.cs
- DBCommand.cs
- IUnknownConstantAttribute.cs
- ChannelServices.cs
- CodeDomSerializerException.cs
- CustomErrorCollection.cs
- ListSortDescriptionCollection.cs
- PenContext.cs
- ErrorWebPart.cs
- GridLength.cs
- TypedRowGenerator.cs
- SslStreamSecurityElement.cs
- WmlLinkAdapter.cs
- TypeUtil.cs
- Debugger.cs
- SectionRecord.cs
- SequentialWorkflowHeaderFooter.cs
- EditorAttribute.cs
- ContractInstanceProvider.cs
- PropertyPathConverter.cs
- UnmanagedHandle.cs
- DataSetMappper.cs
- ListViewItem.cs
- ToolStripSplitStackLayout.cs
- ScrollBarAutomationPeer.cs
- QuestionEventArgs.cs
- ContextDataSourceContextData.cs
- brushes.cs
- ThrowHelper.cs
- BindingsCollection.cs
- EtwTrace.cs
- ProcessManager.cs
- CustomTypeDescriptor.cs
- SourceElementsCollection.cs
- XmlSchemaValidator.cs
- ObjectListCommandsPage.cs
- ButtonFlatAdapter.cs
- RichTextBox.cs
- PropertyEmitterBase.cs
- ColumnTypeConverter.cs
- DependencyPropertyValueSerializer.cs
- ReadContentAsBinaryHelper.cs
- MenuItemBindingCollection.cs
- StylusButtonEventArgs.cs
- XmlSchemaImport.cs
- LiteralTextContainerControlBuilder.cs
- ResourceContainerWrapper.cs
- DescendentsWalkerBase.cs
- PingReply.cs
- DataColumnMappingCollection.cs
- SafeFileHandle.cs
- TextTreeText.cs