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
- PropagatorResult.cs
- HtmlHead.cs
- ByteAnimationUsingKeyFrames.cs
- MissingMemberException.cs
- GridViewRowPresenter.cs
- XmlLanguageConverter.cs
- InstanceContextMode.cs
- SQLDoubleStorage.cs
- SharedHttpTransportManager.cs
- CreateUserErrorEventArgs.cs
- safesecurityhelperavalon.cs
- _ListenerRequestStream.cs
- WaitForChangedResult.cs
- SqlIdentifier.cs
- MorphHelpers.cs
- DBConcurrencyException.cs
- ADMembershipUser.cs
- DependencySource.cs
- RotateTransform.cs
- DataGridLinkButton.cs
- CodeAttributeDeclaration.cs
- StandardBindingElementCollection.cs
- BackgroundFormatInfo.cs
- DisplayNameAttribute.cs
- _RegBlobWebProxyDataBuilder.cs
- MimeObjectFactory.cs
- ServiceAuthorizationBehavior.cs
- PackWebRequestFactory.cs
- MD5CryptoServiceProvider.cs
- ParallelTimeline.cs
- ScrollBar.cs
- ConfigXmlWhitespace.cs
- XPathNavigatorReader.cs
- PEFileEvidenceFactory.cs
- TileBrush.cs
- CustomLineCap.cs
- XmlAttributes.cs
- ConfigXmlSignificantWhitespace.cs
- XPathArrayIterator.cs
- AttributeInfo.cs
- Double.cs
- CorrelationKeyCalculator.cs
- SafeFileMapViewHandle.cs
- UserControl.cs
- ComponentChangedEvent.cs
- ByteStack.cs
- IDataContractSurrogate.cs
- TrackingStringDictionary.cs
- ScriptMethodAttribute.cs
- StringUtil.cs
- FlowDocumentReader.cs
- TextSchema.cs
- WebPartEditorApplyVerb.cs
- PeerNameRecord.cs
- HttpCookie.cs
- HyperlinkAutomationPeer.cs
- ReferenceService.cs
- RichTextBoxConstants.cs
- InlineUIContainer.cs
- RpcResponse.cs
- EdmPropertyAttribute.cs
- WebBrowser.cs
- CloseSequence.cs
- BamlTreeUpdater.cs
- CodeValidator.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- GC.cs
- InkCanvasFeedbackAdorner.cs
- SecUtil.cs
- RestHandler.cs
- ImageSource.cs
- NetworkCredential.cs
- TemplateControlCodeDomTreeGenerator.cs
- TextSelectionHighlightLayer.cs
- RegisteredDisposeScript.cs
- AnnotationMap.cs
- IPipelineRuntime.cs
- FormsIdentity.cs
- NonBatchDirectoryCompiler.cs
- BeginEvent.cs
- DynamicDataExtensions.cs
- ToolStripDesignerAvailabilityAttribute.cs
- httpstaticobjectscollection.cs
- XmlEncoding.cs
- ThicknessKeyFrameCollection.cs
- ScrollEvent.cs
- Line.cs
- Stream.cs
- Vertex.cs
- ImplicitInputBrush.cs
- AnnotationAuthorChangedEventArgs.cs
- MinMaxParagraphWidth.cs
- MouseDevice.cs
- SpecialFolderEnumConverter.cs
- FontStretch.cs
- InkCanvas.cs
- securitycriticaldataClass.cs
- ListenerSessionConnectionReader.cs
- XmlAnyAttributeAttribute.cs
- GridViewUpdateEventArgs.cs