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
- XmlDigitalSignatureProcessor.cs
- RegisteredDisposeScript.cs
- VariableAction.cs
- MulticastIPAddressInformationCollection.cs
- CaseInsensitiveComparer.cs
- OleDbCommandBuilder.cs
- MailAddress.cs
- ImageList.cs
- ToolboxItem.cs
- DropShadowBitmapEffect.cs
- View.cs
- StyleModeStack.cs
- TypeSystem.cs
- InsufficientExecutionStackException.cs
- UserNamePasswordValidationMode.cs
- TdsValueSetter.cs
- OracleRowUpdatedEventArgs.cs
- OleDbRowUpdatedEvent.cs
- ListenerHandler.cs
- BlurBitmapEffect.cs
- SemanticResultValue.cs
- MaterialGroup.cs
- ImmutableObjectAttribute.cs
- LookupTables.cs
- JsonDeserializer.cs
- DriveInfo.cs
- EdmSchemaError.cs
- CTreeGenerator.cs
- ToggleButton.cs
- ItemCollection.cs
- MoveSizeWinEventHandler.cs
- WithParamAction.cs
- BuilderInfo.cs
- SecurityHelper.cs
- DataGridViewSelectedColumnCollection.cs
- StateChangeEvent.cs
- ISessionStateStore.cs
- TypeToTreeConverter.cs
- SplitContainerDesigner.cs
- LowerCaseStringConverter.cs
- SafeRegistryHandle.cs
- XmlUtf8RawTextWriter.cs
- FixedPage.cs
- RefreshPropertiesAttribute.cs
- DownloadProgressEventArgs.cs
- ADMembershipProvider.cs
- MessageQueuePermissionEntry.cs
- BufferBuilder.cs
- Rect3DConverter.cs
- XPathMultyIterator.cs
- WindowsTooltip.cs
- CompositeFontFamily.cs
- ObjectDataSource.cs
- StylusCollection.cs
- DocumentPaginator.cs
- Section.cs
- EncoderParameters.cs
- ProvidePropertyAttribute.cs
- SizeAnimationClockResource.cs
- AttributeEmitter.cs
- PagesChangedEventArgs.cs
- MsmqMessageProperty.cs
- SuspendDesigner.cs
- SqlProfileProvider.cs
- DockAndAnchorLayout.cs
- MenuEventArgs.cs
- PrintDocument.cs
- TypeNameConverter.cs
- WindowsNonControl.cs
- RSAOAEPKeyExchangeFormatter.cs
- FilterElement.cs
- PageParser.cs
- CommandManager.cs
- JsonWriter.cs
- SingleSelectRootGridEntry.cs
- GuidTagList.cs
- Schedule.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- ImageIndexConverter.cs
- SingleSelectRootGridEntry.cs
- Int32Storage.cs
- FontSourceCollection.cs
- MessageBox.cs
- AstTree.cs
- SecurityPolicySection.cs
- WebPartCloseVerb.cs
- ToolboxItem.cs
- XmlSchemaRedefine.cs
- AssociationType.cs
- ValuePattern.cs
- WSHttpBindingCollectionElement.cs
- ObjectFullSpanRewriter.cs
- DesignTimeParseData.cs
- RowType.cs
- ToRequest.cs
- Button.cs
- BamlRecordReader.cs
- WebPartZoneBase.cs
- AuthenticationService.cs
- CodeNamespaceImport.cs