Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / 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. //---------------------------------------------------------------------------- // // 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
- PlatformNotSupportedException.cs
- ControlCommandSet.cs
- FileVersionInfo.cs
- PlatformNotSupportedException.cs
- EncodingNLS.cs
- RuleConditionDialog.cs
- WMIInterop.cs
- MaterialGroup.cs
- Root.cs
- ChildDocumentBlock.cs
- WebPartTransformer.cs
- ConsumerConnectionPoint.cs
- SqlRemoveConstantOrderBy.cs
- COM2Properties.cs
- Variant.cs
- MapPathBasedVirtualPathProvider.cs
- SHA1CryptoServiceProvider.cs
- SiteMap.cs
- ISO2022Encoding.cs
- IntranetCredentialPolicy.cs
- ZoneMembershipCondition.cs
- AuthenticationSection.cs
- SrgsSubset.cs
- UnknownBitmapEncoder.cs
- Vector3DAnimationBase.cs
- StateItem.cs
- ISessionStateStore.cs
- XsltOutput.cs
- RenameRuleObjectDialog.Designer.cs
- listitem.cs
- COAUTHIDENTITY.cs
- DispatcherHooks.cs
- PropertyTabAttribute.cs
- StoreItemCollection.cs
- HitTestParameters.cs
- TrueReadOnlyCollection.cs
- XMLUtil.cs
- DataGridViewComboBoxCell.cs
- ExternalException.cs
- CompilerErrorCollection.cs
- WebBrowserNavigatingEventHandler.cs
- documentsequencetextview.cs
- HostedElements.cs
- SerialErrors.cs
- TemplatingOptionsDialog.cs
- HtmlWindowCollection.cs
- DataGridViewIntLinkedList.cs
- WebPageTraceListener.cs
- PropertyDescriptor.cs
- HtmlContainerControl.cs
- Dispatcher.cs
- CornerRadiusConverter.cs
- CalloutQueueItem.cs
- SqlDataSourceCache.cs
- PropertyNames.cs
- SyntaxCheck.cs
- SqlExpander.cs
- SoapAttributeOverrides.cs
- Peer.cs
- SiteIdentityPermission.cs
- ImpersonateTokenRef.cs
- CompilerParameters.cs
- SafeNativeMethodsCLR.cs
- Expander.cs
- BaseWebProxyFinder.cs
- TextDecoration.cs
- TrackingLocationCollection.cs
- ListViewItemCollectionEditor.cs
- ExtensionFile.cs
- LowerCaseStringConverter.cs
- ColorAnimationBase.cs
- RecordConverter.cs
- NumberFormatInfo.cs
- XamlSerializerUtil.cs
- GridViewRowPresenter.cs
- ObfuscateAssemblyAttribute.cs
- QilStrConcat.cs
- ClickablePoint.cs
- XamlStyleSerializer.cs
- controlskin.cs
- BrowserCapabilitiesCodeGenerator.cs
- RowToFieldTransformer.cs
- ColorTransform.cs
- Localizer.cs
- LinkClickEvent.cs
- Compiler.cs
- _AutoWebProxyScriptEngine.cs
- ListControlActionList.cs
- DataGridViewHeaderCell.cs
- BooleanStorage.cs
- ToolStripComboBox.cs
- ToolStripPanelRow.cs
- MultiView.cs
- SubMenuStyle.cs
- Table.cs
- DataBindingList.cs
- RegistrationServices.cs
- Light.cs
- DeferrableContent.cs
- XmlUtil.cs