Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Base / System / Windows / Input / KeyValueSerializer.cs / 1 / KeyValueSerializer.cs
//----------------------------------------------------------------------------
//
// File: KeyValueSerializer.cs
//
// Description:
//
// KeyValueSerializer: Serializes a key string to a string and vice-versa
//
// Features:
//
// History:
// 08/04/2005 created: Chuck Jazdzewski
//
// Copyright (C) 2005 by Microsoft Corporation. All rights reserved.
//
//---------------------------------------------------------------------------
using System;
using System.ComponentModel; // for TypeConverter
using System.Globalization; // for CultureInfo
using System.Reflection;
using System.Windows;
using System.Windows.Input;
using System.Windows.Markup;
using System.Security.Permissions;
using MS.Utility;
namespace System.Windows.Input
{
///
/// Key Serializer class for serializing a Key
///
///
public class KeyValueSerializer : ValueSerializer
{
///
/// CanConvertFromString()
///
///
///
///
///
public override bool CanConvertFromString(string value, IValueSerializerContext context)
{
return true;
}
///
/// CanConvertToString()
///
///
///
///
///
public override bool CanConvertToString(object value, IValueSerializerContext context)
{
if (!(value is Key))
return false;
Key key = (Key)value;
return ((int)key >= (int)Key.None && (int)key <= (int)Key.OemClear);
}
///
/// ConvertFromString()
///
///
///
///
public override object ConvertFromString(string value, IValueSerializerContext context)
{
TypeConverter converter = TypeDescriptor.GetConverter(typeof(Key));
if (converter != null)
return converter.ConvertFromString(value);
else
return base.ConvertFromString(value, context);
}
///
/// ConvertToString()
///
///
///
///
public override string ConvertToString(object value, IValueSerializerContext context)
{
TypeConverter converter = TypeDescriptor.GetConverter(typeof(Key));
if (converter != null)
return converter.ConvertToInvariantString(value);
else
return base.ConvertToString(value, context);
}
}
}
// 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
- PartitionResolver.cs
- Win32.cs
- GacUtil.cs
- ColorAnimationBase.cs
- FontNameConverter.cs
- OperationAbortedException.cs
- AppDomainInstanceProvider.cs
- HtmlProps.cs
- WebServiceTypeData.cs
- graph.cs
- XamlSerializerUtil.cs
- RoutingBehavior.cs
- WebZone.cs
- LocalBuilder.cs
- DefaultExpression.cs
- CompilerErrorCollection.cs
- JoinCqlBlock.cs
- EnumerableRowCollectionExtensions.cs
- IssuanceLicense.cs
- OutputCacheProfile.cs
- DataListItemCollection.cs
- KnownTypeDataContractResolver.cs
- RuntimeTrackingProfile.cs
- XamlInt32CollectionSerializer.cs
- DbModificationCommandTree.cs
- PriorityRange.cs
- NotificationContext.cs
- XmlSchemaValidator.cs
- Point3D.cs
- Container.cs
- TraceShell.cs
- WindowsHyperlink.cs
- IDQuery.cs
- RawContentTypeMapper.cs
- UpdatePanelTriggerCollection.cs
- SeverityFilter.cs
- DataGridViewColumn.cs
- RecordConverter.cs
- DataGridPagerStyle.cs
- GenericWebPart.cs
- HttpResponse.cs
- OdbcEnvironment.cs
- IApplicationTrustManager.cs
- ModuleBuilder.cs
- RequestCacheValidator.cs
- XsltOutput.cs
- TraceUtility.cs
- PointAnimationUsingPath.cs
- SoapMessage.cs
- Memoizer.cs
- LabelAutomationPeer.cs
- WindowsSpinner.cs
- RenderingEventArgs.cs
- Rijndael.cs
- DataObject.cs
- HtmlCommandAdapter.cs
- XmlSchemaAttributeGroupRef.cs
- EventlogProvider.cs
- MemberMaps.cs
- Rules.cs
- basemetadatamappingvisitor.cs
- HTTPAPI_VERSION.cs
- ContravarianceAdapter.cs
- XmlMessageFormatter.cs
- ConfigurationStrings.cs
- SessionStateContainer.cs
- SmiContext.cs
- WebPartDescription.cs
- RegexCapture.cs
- DataGridViewIntLinkedList.cs
- TypeExtensionConverter.cs
- PieceDirectory.cs
- RestHandlerFactory.cs
- KeyValuePair.cs
- RowToFieldTransformer.cs
- ArgumentException.cs
- WriteTimeStream.cs
- SupportsEventValidationAttribute.cs
- RegexBoyerMoore.cs
- ListViewSelectEventArgs.cs
- BindingsCollection.cs
- JournalEntry.cs
- CoreSwitches.cs
- BasicCommandTreeVisitor.cs
- FloaterBaseParaClient.cs
- GeometryGroup.cs
- Buffer.cs
- NativeBuffer.cs
- ConsoleKeyInfo.cs
- UndoUnit.cs
- TailPinnedEventArgs.cs
- SystemColors.cs
- PointCollectionConverter.cs
- WmlControlAdapter.cs
- OracleString.cs
- OdbcEnvironment.cs
- ClassHandlersStore.cs
- CodeMemberEvent.cs
- SimpleBitVector32.cs
- cache.cs