Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- PropertyChangedEventArgs.cs
- wgx_exports.cs
- PersistChildrenAttribute.cs
- FixedPageProcessor.cs
- SymDocumentType.cs
- PasswordRecovery.cs
- Privilege.cs
- TextWriterEngine.cs
- OdbcConnectionFactory.cs
- ImpersonationContext.cs
- ExpressionBuilder.cs
- ReversePositionQuery.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- XmlImplementation.cs
- MasterPageCodeDomTreeGenerator.cs
- OptimizerPatterns.cs
- OracleConnectionFactory.cs
- PlainXmlWriter.cs
- DataGridViewSortCompareEventArgs.cs
- ChildrenQuery.cs
- CustomValidator.cs
- TypeSource.cs
- HttpServerUtilityWrapper.cs
- SecurityProtocolCorrelationState.cs
- Transform3DCollection.cs
- XmlDownloadManager.cs
- ResetableIterator.cs
- sqlpipe.cs
- DataAdapter.cs
- XmlNodeList.cs
- AxisAngleRotation3D.cs
- StrokeNodeEnumerator.cs
- FileDialog.cs
- Propagator.JoinPropagator.SubstitutingCloneVisitor.cs
- ToolStripRenderEventArgs.cs
- LoadedOrUnloadedOperation.cs
- StreamGeometry.cs
- FileUpload.cs
- SoapClientProtocol.cs
- TypeUsageBuilder.cs
- AliasExpr.cs
- ShapingEngine.cs
- HttpResponseWrapper.cs
- HttpValueCollection.cs
- ComNativeDescriptor.cs
- RoutedEventValueSerializer.cs
- CryptoStream.cs
- DSASignatureDeformatter.cs
- HttpCookieCollection.cs
- ExpressionEditorAttribute.cs
- BinaryObjectInfo.cs
- InlineCollection.cs
- GeneralTransformGroup.cs
- UriSection.cs
- UnsafeNativeMethods.cs
- QueryConverter.cs
- TextFormatter.cs
- BehaviorEditorPart.cs
- MetafileHeaderWmf.cs
- Stack.cs
- XamlTreeBuilderBamlRecordWriter.cs
- HelpProvider.cs
- XmlConvert.cs
- DataGridViewCellLinkedList.cs
- TreeNode.cs
- XmlSchemaGroup.cs
- DataGridColumnHeadersPresenter.cs
- PrinterResolution.cs
- StorageEndPropertyMapping.cs
- FileDialog_Vista_Interop.cs
- Pair.cs
- DiscoveryServiceExtension.cs
- DesignerValidationSummaryAdapter.cs
- FileDialog_Vista.cs
- updatecommandorderer.cs
- TextElementAutomationPeer.cs
- FilterEventArgs.cs
- CryptographicAttribute.cs
- InputLangChangeEvent.cs
- COAUTHIDENTITY.cs
- HelpKeywordAttribute.cs
- FixedSOMTextRun.cs
- ParagraphResult.cs
- MimePart.cs
- MethodSignatureGenerator.cs
- WindowsRichEditRange.cs
- ClonableStack.cs
- RectValueSerializer.cs
- GatewayIPAddressInformationCollection.cs
- SqlClientWrapperSmiStreamChars.cs
- VirtualPathProvider.cs
- CatalogZone.cs
- DesignTimeType.cs
- TemplateContentLoader.cs
- IsolationInterop.cs
- BitmapEffectGeneralTransform.cs
- Control.cs
- BitmapEffectState.cs
- PageHandlerFactory.cs
- DataBindingCollection.cs