Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- ZoneLinkButton.cs
- Utils.cs
- RegexRunnerFactory.cs
- CellTreeNodeVisitors.cs
- DetailsViewPageEventArgs.cs
- ScrollChrome.cs
- TextLineResult.cs
- IListConverters.cs
- HostnameComparisonMode.cs
- ListSortDescription.cs
- AddInStore.cs
- DataBoundControlHelper.cs
- XmlAttributeCache.cs
- Mutex.cs
- TableHeaderCell.cs
- TreeViewAutomationPeer.cs
- PageContentAsyncResult.cs
- GroupAggregateExpr.cs
- httpapplicationstate.cs
- Selector.cs
- SharedUtils.cs
- WebPartConnectionsConfigureVerb.cs
- SystemKeyConverter.cs
- StylusOverProperty.cs
- Tokenizer.cs
- DbModificationCommandTree.cs
- ConnectionsZone.cs
- EntityDataSourceStatementEditor.cs
- XPathMessageFilter.cs
- XmlILStorageConverter.cs
- DataTableTypeConverter.cs
- URLAttribute.cs
- CompositeFontInfo.cs
- BamlResourceContent.cs
- StreamingContext.cs
- SqlBooleanizer.cs
- TextParagraph.cs
- CryptoApi.cs
- DataGridViewToolTip.cs
- ModelItem.cs
- ListViewCancelEventArgs.cs
- SoapSchemaExporter.cs
- WinEventWrap.cs
- EmptyStringExpandableObjectConverter.cs
- WebPartConnectionsCancelEventArgs.cs
- ThreadAbortException.cs
- ZoneMembershipCondition.cs
- CodeDelegateInvokeExpression.cs
- PathFigureCollectionConverter.cs
- NameValueFileSectionHandler.cs
- MemberNameValidator.cs
- XmlReflectionImporter.cs
- ValidatedControlConverter.cs
- DataObjectPastingEventArgs.cs
- MimeTypeMapper.cs
- ControlCachePolicy.cs
- DriveNotFoundException.cs
- ThicknessKeyFrameCollection.cs
- serverconfig.cs
- SmtpSection.cs
- TemplateApplicationHelper.cs
- LabelTarget.cs
- WebPartExportVerb.cs
- WebConfigManager.cs
- RemotingConfigParser.cs
- TextTreeObjectNode.cs
- SendMailErrorEventArgs.cs
- MD5.cs
- PartialList.cs
- SqlMultiplexer.cs
- MyContact.cs
- LocalizabilityAttribute.cs
- ToolBar.cs
- ResourceCodeDomSerializer.cs
- ToolStripLocationCancelEventArgs.cs
- WebContext.cs
- unitconverter.cs
- CustomAttributeBuilder.cs
- Graphics.cs
- CheckBoxAutomationPeer.cs
- NetDispatcherFaultException.cs
- StructuralObject.cs
- PagedControl.cs
- HandledMouseEvent.cs
- StreamUpdate.cs
- FontStyleConverter.cs
- WindowsImpersonationContext.cs
- ProxyWebPart.cs
- HttpCapabilitiesBase.cs
- DisplayNameAttribute.cs
- NameValueConfigurationElement.cs
- SymLanguageType.cs
- SByte.cs
- BinaryConverter.cs
- MobileControlBuilder.cs
- NumericUpDownAccelerationCollection.cs
- XmlSchemaProviderAttribute.cs
- URLAttribute.cs
- StartUpEventArgs.cs
- _NetRes.cs