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
- StrongNameMembershipCondition.cs
- CurrentChangedEventManager.cs
- TimeSpanValidatorAttribute.cs
- TreeNode.cs
- InputLangChangeEvent.cs
- KeyPullup.cs
- InternalCache.cs
- MdiWindowListStrip.cs
- State.cs
- BuildTopDownAttribute.cs
- SymmetricAlgorithm.cs
- ReferentialConstraint.cs
- SoapSchemaImporter.cs
- ResXBuildProvider.cs
- AspCompat.cs
- WindowVisualStateTracker.cs
- FileLevelControlBuilderAttribute.cs
- IdentitySection.cs
- DataColumnMappingCollection.cs
- Compiler.cs
- ClientScriptManagerWrapper.cs
- PropertyValueUIItem.cs
- XslAstAnalyzer.cs
- SoapSchemaMember.cs
- EdmProviderManifest.cs
- SqlDataSourceConfigureFilterForm.cs
- DynamicAttribute.cs
- DateRangeEvent.cs
- XmlElementAttributes.cs
- safelinkcollection.cs
- WebBrowsableAttribute.cs
- DataViewSettingCollection.cs
- DataGridViewRow.cs
- Message.cs
- SqlParameter.cs
- Debug.cs
- OperationCanceledException.cs
- RequiredAttributeAttribute.cs
- Propagator.cs
- FlowSwitchLink.cs
- SecurityHeaderElementInferenceEngine.cs
- TableCellCollection.cs
- HostedHttpRequestAsyncResult.cs
- DocumentPageViewAutomationPeer.cs
- ConversionHelper.cs
- RSACryptoServiceProvider.cs
- Clause.cs
- TableItemPattern.cs
- GeneralTransform.cs
- SecurityRuntime.cs
- DataColumnPropertyDescriptor.cs
- ReadOnlyTernaryTree.cs
- CalendarDateRangeChangingEventArgs.cs
- PageParserFilter.cs
- PenLineJoinValidation.cs
- VirtualPathUtility.cs
- Matrix3D.cs
- IgnorePropertiesAttribute.cs
- _IPv4Address.cs
- DataSysAttribute.cs
- GroupBox.cs
- ContainerControl.cs
- RefreshPropertiesAttribute.cs
- WriteableBitmap.cs
- KnownBoxes.cs
- TableCellAutomationPeer.cs
- RotateTransform3D.cs
- ConditionCollection.cs
- NullReferenceException.cs
- SerializerWriterEventHandlers.cs
- SerialErrors.cs
- ConnectionManager.cs
- Compensate.cs
- ActivityDesigner.cs
- HttpPostClientProtocol.cs
- Environment.cs
- ConsoleKeyInfo.cs
- Mutex.cs
- SecurityProtocolCorrelationState.cs
- HttpApplication.cs
- AssemblyCollection.cs
- EditorZoneBase.cs
- Label.cs
- ZipIOModeEnforcingStream.cs
- NamedPermissionSet.cs
- ToggleProviderWrapper.cs
- ImageListUtils.cs
- ContainsSearchOperator.cs
- SlotInfo.cs
- InternalSafeNativeMethods.cs
- WebBrowserPermission.cs
- ActivityPreviewDesigner.cs
- PropertyDescriptorComparer.cs
- FrameworkRichTextComposition.cs
- AutoSizeComboBox.cs
- ColorTransform.cs
- MaskedTextBoxDesignerActionList.cs
- TableRowCollection.cs
- Win32Exception.cs
- XamlFigureLengthSerializer.cs