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
- FunctionParameter.cs
- Visual3D.cs
- DashStyle.cs
- ParseElement.cs
- TargetParameterCountException.cs
- VisualCollection.cs
- TextContainerChangedEventArgs.cs
- Header.cs
- BitVector32.cs
- SqlConnectionHelper.cs
- FileDetails.cs
- ReverseInheritProperty.cs
- RequestCacheManager.cs
- XpsFilter.cs
- XmlResolver.cs
- NewExpression.cs
- XmlHierarchyData.cs
- XPathNodeIterator.cs
- TextBoxBase.cs
- MSG.cs
- CompilerGlobalScopeAttribute.cs
- RoutedUICommand.cs
- NumericUpDown.cs
- HtmlFormWrapper.cs
- formatter.cs
- BitmapEffectDrawing.cs
- ReadOnlyNameValueCollection.cs
- SimpleWorkerRequest.cs
- SafeRightsManagementSessionHandle.cs
- PersonalizablePropertyEntry.cs
- _ChunkParse.cs
- Cursors.cs
- MetadataUtilsSmi.cs
- ValidationHelpers.cs
- ApplicationId.cs
- RSAPKCS1KeyExchangeFormatter.cs
- ControlLocalizer.cs
- HtmlInputButton.cs
- FramingEncoders.cs
- ConstraintManager.cs
- SecurityCookieModeValidator.cs
- WaitHandle.cs
- SecurityTokenSerializer.cs
- SchemaRegistration.cs
- GlobalizationAssembly.cs
- SimpleTableProvider.cs
- PathTooLongException.cs
- AnnotationAdorner.cs
- PreservationFileWriter.cs
- ServiceDescriptionData.cs
- EntityCollection.cs
- EnumValAlphaComparer.cs
- BamlLocalizer.cs
- ScrollBarAutomationPeer.cs
- JapaneseLunisolarCalendar.cs
- XmlSchemas.cs
- GridViewCancelEditEventArgs.cs
- ServicesUtilities.cs
- ServiceChannelManager.cs
- SendingRequestEventArgs.cs
- Renderer.cs
- WebPartConnectionCollection.cs
- XmlMtomWriter.cs
- RunInstallerAttribute.cs
- TCPClient.cs
- ConstraintManager.cs
- TextServicesCompartmentContext.cs
- SecurityException.cs
- CheckedListBox.cs
- MessageQueueInstaller.cs
- X509Certificate2Collection.cs
- ControlLocalizer.cs
- CheckBoxStandardAdapter.cs
- SqlFacetAttribute.cs
- CqlWriter.cs
- DataGridViewCellValidatingEventArgs.cs
- StrokeFIndices.cs
- COM2IVsPerPropertyBrowsingHandler.cs
- WinFormsSecurity.cs
- OleDbReferenceCollection.cs
- ComponentEditorPage.cs
- ConfigurationValidatorBase.cs
- KeyValuePairs.cs
- TrackBar.cs
- Stopwatch.cs
- ContentPlaceHolder.cs
- BroadcastEventHelper.cs
- GenericTypeParameterConverter.cs
- StateWorkerRequest.cs
- DataViewListener.cs
- SystemPens.cs
- SqlNode.cs
- HttpCachePolicyElement.cs
- MeshGeometry3D.cs
- GridViewRowPresenterBase.cs
- DataTable.cs
- OleStrCAMarshaler.cs
- HttpPostServerProtocol.cs
- Window.cs
- QueryRewriter.cs