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
- Trace.cs
- DBSchemaTable.cs
- SqlMethodTransformer.cs
- HtmlHistory.cs
- ByteStack.cs
- PageThemeBuildProvider.cs
- LinqDataSourceUpdateEventArgs.cs
- BitmapImage.cs
- FileSecurity.cs
- NavigationService.cs
- Version.cs
- MultiTargetingUtil.cs
- DirectoryInfo.cs
- SqlClientMetaDataCollectionNames.cs
- AsymmetricKeyExchangeDeformatter.cs
- CompoundFileIOPermission.cs
- OleDbError.cs
- OleDbDataAdapter.cs
- RegistryExceptionHelper.cs
- ThreadExceptionDialog.cs
- Border.cs
- PlatformNotSupportedException.cs
- sitestring.cs
- ItemCollection.cs
- PeerApplicationLaunchInfo.cs
- DateTimeSerializationSection.cs
- BindingNavigator.cs
- SectionInput.cs
- PrtTicket_Public.cs
- PolicyManager.cs
- DataServiceQueryContinuation.cs
- UserControlParser.cs
- ObjectDataSourceChooseMethodsPanel.cs
- DbConnectionPoolIdentity.cs
- GridViewSortEventArgs.cs
- SqlReferenceCollection.cs
- SHA256.cs
- RegexCaptureCollection.cs
- Italic.cs
- Stylus.cs
- MetadataItemEmitter.cs
- LinqDataSourceView.cs
- SiteMapSection.cs
- AutoResetEvent.cs
- Point4DConverter.cs
- StylusCollection.cs
- RowUpdatedEventArgs.cs
- FileNotFoundException.cs
- CrossSiteScriptingValidation.cs
- SEHException.cs
- Config.cs
- ImpersonationContext.cs
- FunctionUpdateCommand.cs
- HuffCodec.cs
- SvcMapFileSerializer.cs
- XslTransform.cs
- TransportElement.cs
- ScriptIgnoreAttribute.cs
- DateTimeFormatInfo.cs
- XmlDataSourceNodeDescriptor.cs
- DataGridViewColumnCollection.cs
- HtmlInputCheckBox.cs
- DesignerDataStoredProcedure.cs
- QuotedPrintableStream.cs
- ListViewUpdateEventArgs.cs
- LoadItemsEventArgs.cs
- WebBrowserNavigatingEventHandler.cs
- UDPClient.cs
- GlobalDataBindingHandler.cs
- NetworkInterface.cs
- InternalPermissions.cs
- DataGrid.cs
- TypeDelegator.cs
- BamlBinaryWriter.cs
- Deflater.cs
- InitiatorSessionSymmetricMessageSecurityProtocol.cs
- ConnectivityStatus.cs
- HtmlTableCellCollection.cs
- ScriptDescriptor.cs
- RenderCapability.cs
- PreloadHost.cs
- NetworkInformationException.cs
- AsnEncodedData.cs
- WindowsStartMenu.cs
- QueryResult.cs
- CommandHelpers.cs
- Environment.cs
- DefaultPrintController.cs
- DataTableExtensions.cs
- QilLiteral.cs
- ContractAdapter.cs
- Relationship.cs
- UpdateTranslator.cs
- BamlReader.cs
- AppDomainManager.cs
- CodeTypeConstructor.cs
- StylesEditorDialog.cs
- ProtocolsSection.cs
- ToolStripItem.cs
- ItemContainerGenerator.cs