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
- SendingRequestEventArgs.cs
- Timer.cs
- HttpCachePolicyElement.cs
- NativeMethods.cs
- Module.cs
- SafeViewOfFileHandle.cs
- ProcessHostMapPath.cs
- RoutedUICommand.cs
- Renderer.cs
- ExpressionList.cs
- GridEntry.cs
- ModelItemCollectionImpl.cs
- ToolStripDropDownItemDesigner.cs
- XmlDataLoader.cs
- DataRecordObjectView.cs
- ViewGenResults.cs
- DurableMessageDispatchInspector.cs
- ScalarConstant.cs
- UniqueIdentifierService.cs
- ObjectKeyFrameCollection.cs
- ContextMenu.cs
- MessageQueueKey.cs
- MethodRental.cs
- BaseAutoFormat.cs
- UsernameTokenFactoryCredential.cs
- DataContractSerializerSection.cs
- ExtendedProtectionPolicy.cs
- ConnectionManagementSection.cs
- ComboBoxAutomationPeer.cs
- DataTemplateKey.cs
- MethodRental.cs
- WebPartDisplayModeCollection.cs
- DecimalAnimationBase.cs
- _TransmitFileOverlappedAsyncResult.cs
- CompiledAction.cs
- SymbolDocumentInfo.cs
- UntypedNullExpression.cs
- ErrorLog.cs
- X509SecurityTokenAuthenticator.cs
- _TimerThread.cs
- RoleManagerEventArgs.cs
- PermissionAttributes.cs
- PageWrapper.cs
- ParseChildrenAsPropertiesAttribute.cs
- DataGridViewCheckBoxColumn.cs
- FragmentQuery.cs
- OracleException.cs
- XmlArrayItemAttribute.cs
- Registration.cs
- SourceItem.cs
- UnderstoodHeaders.cs
- EndPoint.cs
- ControlParameter.cs
- NullExtension.cs
- UnsafeNativeMethodsCLR.cs
- BitArray.cs
- SimpleHandlerFactory.cs
- WindowsIdentity.cs
- ControlDesignerState.cs
- StorageRoot.cs
- OutputCacheSection.cs
- XmlSchemaIdentityConstraint.cs
- BezierSegment.cs
- ForeignConstraint.cs
- NativeMethods.cs
- EventWaitHandleSecurity.cs
- XmlSchemaCollection.cs
- SendMailErrorEventArgs.cs
- InheritanceRules.cs
- SendKeys.cs
- InvalidProgramException.cs
- dataprotectionpermission.cs
- recordstatescratchpad.cs
- SqlUserDefinedTypeAttribute.cs
- EllipseGeometry.cs
- UnmanagedBitmapWrapper.cs
- OleDbParameter.cs
- ScriptingAuthenticationServiceSection.cs
- SmtpSection.cs
- GenerateHelper.cs
- CacheManager.cs
- GiveFeedbackEvent.cs
- ColorInterpolationModeValidation.cs
- ConstantSlot.cs
- LinearGradientBrush.cs
- DefaultShape.cs
- CloseCryptoHandleRequest.cs
- SqlConnectionString.cs
- ReadOnlyNameValueCollection.cs
- SQLCharsStorage.cs
- StrongNameIdentityPermission.cs
- RayHitTestParameters.cs
- RewritingPass.cs
- BlurEffect.cs
- Variable.cs
- OdbcConnectionString.cs
- Claim.cs
- SHA256Managed.cs
- WorkflowElementDialog.cs
- input.cs