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
- SoapException.cs
- DbParameterHelper.cs
- ExclusiveTcpListener.cs
- SimpleLine.cs
- FormsIdentity.cs
- ObjectViewEntityCollectionData.cs
- ReaderContextStackData.cs
- LostFocusEventManager.cs
- TraceHandler.cs
- UniqueEventHelper.cs
- OutputCacheProfileCollection.cs
- RoleProviderPrincipal.cs
- DataRecordInfo.cs
- FormClosingEvent.cs
- MachineKeySection.cs
- InheritanceContextChangedEventManager.cs
- XmlSerializerAssemblyAttribute.cs
- X509CertificateChain.cs
- DataGridViewRowPostPaintEventArgs.cs
- SqlMethodCallConverter.cs
- ProcessingInstructionAction.cs
- MarkupCompilePass1.cs
- MetabaseSettingsIis7.cs
- DashStyle.cs
- SafeArrayTypeMismatchException.cs
- XmlSchemaSimpleTypeRestriction.cs
- LazyInitializer.cs
- ExceptionNotification.cs
- ManagedFilter.cs
- BinaryUtilClasses.cs
- SystemWebCachingSectionGroup.cs
- WebPartUserCapability.cs
- WpfXamlMember.cs
- XmlMapping.cs
- FlowDocumentPaginator.cs
- NTAccount.cs
- SimpleApplicationHost.cs
- AutomationEventArgs.cs
- FixedSOMLineRanges.cs
- Int32RectConverter.cs
- SafeLocalMemHandle.cs
- DescriptionAttribute.cs
- Rfc2898DeriveBytes.cs
- AsynchronousChannelMergeEnumerator.cs
- ModelProperty.cs
- InvalidChannelBindingException.cs
- GeneralTransform3DTo2DTo3D.cs
- StructuredTypeEmitter.cs
- DataSet.cs
- IsolatedStoragePermission.cs
- NavigationPropertyEmitter.cs
- DesigntimeLicenseContextSerializer.cs
- DbModificationClause.cs
- DbConnectionPoolGroupProviderInfo.cs
- LingerOption.cs
- WindowProviderWrapper.cs
- SplayTreeNode.cs
- SourceElementsCollection.cs
- _BufferOffsetSize.cs
- CodeIdentifier.cs
- SerializationUtility.cs
- XmlILStorageConverter.cs
- ListSortDescription.cs
- SqlConnectionPoolGroupProviderInfo.cs
- SafeHandles.cs
- SqlNodeAnnotation.cs
- IPCCacheManager.cs
- dbenumerator.cs
- FunctionDescription.cs
- TransactionScopeDesigner.cs
- Rotation3DAnimation.cs
- ZipIOExtraFieldPaddingElement.cs
- FixedPosition.cs
- MarshalByValueComponent.cs
- CharStorage.cs
- UInt32.cs
- ExpressionParser.cs
- ListenerElementsCollection.cs
- ProviderSettings.cs
- HyperLink.cs
- FindSimilarActivitiesVerb.cs
- DataSourceConverter.cs
- EntityDataSourceViewSchema.cs
- SurrogateSelector.cs
- PathSegmentCollection.cs
- SafeMILHandle.cs
- EntityDataSourceContainerNameItem.cs
- XmlElementCollection.cs
- MdiWindowListItemConverter.cs
- SqlDataRecord.cs
- PolicyAssertionCollection.cs
- ActivityXRefConverter.cs
- WsatEtwTraceListener.cs
- TileBrush.cs
- SplitContainer.cs
- DataGridHeaderBorder.cs
- COM2Properties.cs
- _Events.cs
- _SSPIWrapper.cs
- TableItemPatternIdentifiers.cs