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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- GeneralTransform.cs
- SerializationAttributes.cs
- IMembershipProvider.cs
- SmiXetterAccessMap.cs
- CharEnumerator.cs
- CodeTypeReference.cs
- HttpPostedFileBase.cs
- GuidTagList.cs
- Matrix3D.cs
- XamlTemplateSerializer.cs
- DynamicResourceExtension.cs
- EmptyElement.cs
- Walker.cs
- SectionXmlInfo.cs
- ImageMapEventArgs.cs
- BuildResult.cs
- StrokeRenderer.cs
- _ChunkParse.cs
- HtmlCommandAdapter.cs
- VisualTransition.cs
- CopyEncoder.cs
- BuildTopDownAttribute.cs
- XPathBinder.cs
- EventEntry.cs
- ConfigurationManager.cs
- MultilineStringConverter.cs
- TextSelection.cs
- XmlTextReader.cs
- ObjectViewEntityCollectionData.cs
- EntitySqlQueryBuilder.cs
- XPathParser.cs
- DefaultPrintController.cs
- GridViewEditEventArgs.cs
- DataBoundLiteralControl.cs
- XmlTextAttribute.cs
- OrderedDictionaryStateHelper.cs
- DbProviderFactories.cs
- UrlPath.cs
- UriWriter.cs
- BooleanFunctions.cs
- OptimizerPatterns.cs
- KnownTypesHelper.cs
- MSHTMLHostUtil.cs
- SystemTcpConnection.cs
- ProjectionCamera.cs
- LineProperties.cs
- CodeCommentStatement.cs
- StateInitializationDesigner.cs
- VersionedStream.cs
- ResourceExpressionEditorSheet.cs
- _FtpControlStream.cs
- EncoderParameter.cs
- NameObjectCollectionBase.cs
- HScrollBar.cs
- AbstractSvcMapFileLoader.cs
- FilteredAttributeCollection.cs
- IdentityNotMappedException.cs
- SharedDp.cs
- StructuredProperty.cs
- backend.cs
- DynamicUpdateCommand.cs
- FramingDecoders.cs
- Atom10FormatterFactory.cs
- SortQuery.cs
- WebZoneDesigner.cs
- BordersPage.cs
- CompilationLock.cs
- Enum.cs
- CachedCompositeFamily.cs
- PieceDirectory.cs
- IndependentlyAnimatedPropertyMetadata.cs
- FrameDimension.cs
- ExpressionBinding.cs
- SymmetricKeyWrap.cs
- SHA512.cs
- OutOfProcStateClientManager.cs
- CreateDataSourceDialog.cs
- RegexTypeEditor.cs
- ContextMenuService.cs
- DataViewListener.cs
- Preprocessor.cs
- EventSourceCreationData.cs
- PanelDesigner.cs
- NamespaceEmitter.cs
- SchemaNames.cs
- PartialToken.cs
- HttpChannelHelper.cs
- MD5CryptoServiceProvider.cs
- EpmContentSerializerBase.cs
- WinFormsSecurity.cs
- XmlSortKeyAccumulator.cs
- Constant.cs
- EmptyElement.cs
- ScrollEvent.cs
- BooleanExpr.cs
- DataGridViewCellPaintingEventArgs.cs
- CellIdBoolean.cs
- TextDecorations.cs
- LogoValidationException.cs
- EnumMember.cs