Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / System / Windows / DependencyPropertyValueSerializer.cs / 1305600 / DependencyPropertyValueSerializer.cs
//------------------------------------------------------------------------ // // Microsoft Windows Client Platform // Copyright (C) Microsoft Corporation, 2005 // // File: CommandValueSerializer.cs // // Contents: ValueSerializer for DependencyProperty // // Created: 04/28/2005 [....] // //----------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; using System.Windows.Markup; namespace System.Windows { internal class DependencyPropertyValueSerializer : ValueSerializer { public override bool CanConvertToString(object value, IValueSerializerContext context) { return ValueSerializer.GetSerializerFor(typeof(Type), context) != null; } public override bool CanConvertFromString(string value, IValueSerializerContext context) { return ValueSerializer.GetSerializerFor(typeof(Type), context) != null; } public override string ConvertToString(object value, IValueSerializerContext context) { DependencyProperty property = value as DependencyProperty; if (property != null) { ValueSerializer typeSerializer = ValueSerializer.GetSerializerFor(typeof(Type), context); if (typeSerializer != null) { return typeSerializer.ConvertToString(property.OwnerType, context) + "." + property.Name; } } throw GetConvertToException(value, typeof(string)); } public override IEnumerableTypeReferences(object value, IValueSerializerContext context) { DependencyProperty property = value as DependencyProperty; if (property != null) { return new Type[] { property.OwnerType }; } else { return base.TypeReferences(value, context); } } public override object ConvertFromString(string value, IValueSerializerContext context) { ValueSerializer typeSerializer = ValueSerializer.GetSerializerFor(typeof(Type), context); if (typeSerializer != null) { int dotIndex = value.IndexOf('.'); if (dotIndex >= 0) { string typeName = value.Substring(0, dotIndex - 1); Type ownerType = typeSerializer.ConvertFromString(typeName, context) as Type; if (ownerType != null) { return DependencyProperty.FromName(typeName, ownerType); } } } throw GetConvertFromException(value); } } } // 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
- ServiceOperationInfoTypeConverter.cs
- ChildDocumentBlock.cs
- SchemaInfo.cs
- EpmSyndicationContentSerializer.cs
- CalendarDataBindingHandler.cs
- SqlCacheDependency.cs
- ReferenceTypeElement.cs
- PermissionSetTriple.cs
- HostedHttpRequestAsyncResult.cs
- HGlobalSafeHandle.cs
- _AutoWebProxyScriptHelper.cs
- QilChoice.cs
- BoolLiteral.cs
- FamilyTypefaceCollection.cs
- httpserverutility.cs
- PageContentAsyncResult.cs
- CompilationSection.cs
- XmlLanguage.cs
- XmlReader.cs
- XmlHierarchicalEnumerable.cs
- HelpProvider.cs
- QueuePathEditor.cs
- WebPageTraceListener.cs
- DefaultObjectMappingItemCollection.cs
- Emitter.cs
- WebDisplayNameAttribute.cs
- TypeElement.cs
- AudioBase.cs
- TransformerConfigurationWizardBase.cs
- HtmlTitle.cs
- SessionPageStateSection.cs
- OleDbEnumerator.cs
- TrackingWorkflowEventArgs.cs
- XsltOutput.cs
- SystemTcpConnection.cs
- FontNamesConverter.cs
- xsdvalidator.cs
- CryptoKeySecurity.cs
- DBDataPermissionAttribute.cs
- XmlNullResolver.cs
- BCLDebug.cs
- SoapClientMessage.cs
- SequentialActivityDesigner.cs
- SafeCryptoHandles.cs
- TypeKeyValue.cs
- CurrencyManager.cs
- AutomationElementIdentifiers.cs
- MatchingStyle.cs
- GridViewSelectEventArgs.cs
- ServerProtocol.cs
- ObjectStorage.cs
- _AuthenticationState.cs
- ConditionCollection.cs
- TransformedBitmap.cs
- MexTcpBindingCollectionElement.cs
- GifBitmapDecoder.cs
- NotifyInputEventArgs.cs
- InstanceValue.cs
- DependentList.cs
- GeometryModel3D.cs
- DefaultConfirmation.cs
- _FtpDataStream.cs
- ByteStack.cs
- TextModifier.cs
- XmlQualifiedName.cs
- QueryStringParameter.cs
- ItemMap.cs
- MaterialCollection.cs
- Transform3D.cs
- BrowsableAttribute.cs
- DataControlButton.cs
- SqlVersion.cs
- Baml2006KnownTypes.cs
- DoubleLinkList.cs
- TreeViewBindingsEditor.cs
- UInt32.cs
- Parallel.cs
- MappingMetadataHelper.cs
- MissingFieldException.cs
- PenCursorManager.cs
- TextRangeProviderWrapper.cs
- ISFTagAndGuidCache.cs
- Matrix.cs
- CreateParams.cs
- WindowsScroll.cs
- LogEntryDeserializer.cs
- StylusCollection.cs
- PermissionRequestEvidence.cs
- UriScheme.cs
- WorkflowOperationFault.cs
- ProgressChangedEventArgs.cs
- CodeTypeMember.cs
- SoapExtensionReflector.cs
- DateTimeOffsetAdapter.cs
- Int16Converter.cs
- SortDescription.cs
- ObjectDisposedException.cs
- ConnectionConsumerAttribute.cs
- ListViewDataItem.cs
- PKCS1MaskGenerationMethod.cs