Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / System / Windows / Input / KeyValueSerializer.cs / 1305600 / 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. //---------------------------------------------------------------------------- // // 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
- ContextInformation.cs
- SqlDelegatedTransaction.cs
- NativeMsmqMessage.cs
- MediaScriptCommandRoutedEventArgs.cs
- ControlBindingsCollection.cs
- MarkupObject.cs
- WebBrowserEvent.cs
- Point3DKeyFrameCollection.cs
- SqlGatherConsumedAliases.cs
- DataMisalignedException.cs
- BinaryObjectReader.cs
- FormViewActionList.cs
- SelectionUIService.cs
- EntityModelBuildProvider.cs
- XmlTextAttribute.cs
- SessionEndingEventArgs.cs
- StorageBasedPackageProperties.cs
- ManifestResourceInfo.cs
- UpdateManifestForBrowserApplication.cs
- DoubleIndependentAnimationStorage.cs
- DBCSCodePageEncoding.cs
- NodeFunctions.cs
- FormatSettings.cs
- AttributeCollection.cs
- HostedHttpRequestAsyncResult.cs
- ImageFormatConverter.cs
- metadatamappinghashervisitor.cs
- ExpressionBuilder.cs
- StringHandle.cs
- XamlSerializer.cs
- ConditionalAttribute.cs
- XmlUnspecifiedAttribute.cs
- SafeFileMappingHandle.cs
- TraceShell.cs
- Int32Animation.cs
- CardSpaceShim.cs
- RemotingAttributes.cs
- EventData.cs
- SafeFindHandle.cs
- InvokeMethodActivity.cs
- ToolboxComponentsCreatingEventArgs.cs
- HyperLinkStyle.cs
- NamedObject.cs
- SafeFileMappingHandle.cs
- BitmapEffectDrawing.cs
- HttpCacheParams.cs
- ObjectListTitleAttribute.cs
- TypeLoader.cs
- SmtpFailedRecipientsException.cs
- DataPagerFieldCollection.cs
- SafeLibraryHandle.cs
- XmlNullResolver.cs
- ObjectTag.cs
- RecipientInfo.cs
- StringFreezingAttribute.cs
- SignatureDescription.cs
- PreservationFileReader.cs
- IisTraceListener.cs
- HttpModuleCollection.cs
- MessageOperationFormatter.cs
- EmptyStringExpandableObjectConverter.cs
- SqlProviderManifest.cs
- Timer.cs
- Identifier.cs
- ForceCopyBuildProvider.cs
- MenuItemStyleCollection.cs
- Mappings.cs
- RequestCache.cs
- PersonalizationStateInfo.cs
- AuthenticationService.cs
- Error.cs
- BuildProviderAppliesToAttribute.cs
- InvalidateEvent.cs
- WebPartDesigner.cs
- MultiBinding.cs
- parserscommon.cs
- PropertiesTab.cs
- ToolboxComponentsCreatedEventArgs.cs
- StateChangeEvent.cs
- DesignerActionUIStateChangeEventArgs.cs
- BindingEntityInfo.cs
- XmlConvert.cs
- ErasingStroke.cs
- SmiEventStream.cs
- TemplatePagerField.cs
- HashCodeCombiner.cs
- CanExpandCollapseAllConverter.cs
- FontSizeConverter.cs
- TextBlockAutomationPeer.cs
- TypeDescriptorFilterService.cs
- WsdlBuildProvider.cs
- Point3DCollection.cs
- Set.cs
- PointHitTestResult.cs
- ServiceObjectContainer.cs
- HtmlLink.cs
- FieldMetadata.cs
- basenumberconverter.cs
- StrongNamePublicKeyBlob.cs
- AdjustableArrowCap.cs