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
- ConsumerConnectionPoint.cs
- ExtensibleClassFactory.cs
- reliableinputsessionchannel.cs
- DataGrid.cs
- ThreadPool.cs
- ConvertersCollection.cs
- SqlIdentifier.cs
- AnnotationResourceChangedEventArgs.cs
- StringUtil.cs
- TableRow.cs
- ReadOnlyNameValueCollection.cs
- ManagedWndProcTracker.cs
- MultiBinding.cs
- InteropAutomationProvider.cs
- FixedSOMFixedBlock.cs
- DataGridViewRowPrePaintEventArgs.cs
- Column.cs
- SafeWaitHandle.cs
- InternalTypeHelper.cs
- SpeechUI.cs
- DaylightTime.cs
- UriSection.cs
- TranslateTransform3D.cs
- PathNode.cs
- IItemProperties.cs
- LoginName.cs
- HebrewNumber.cs
- ExpressionHelper.cs
- TransformerInfoCollection.cs
- CodeSubDirectoriesCollection.cs
- ObjectCloneHelper.cs
- _FtpDataStream.cs
- DataObjectAttribute.cs
- SoapSchemaImporter.cs
- CustomSignedXml.cs
- ListViewItem.cs
- CryptographicAttribute.cs
- ErrorWrapper.cs
- _LocalDataStore.cs
- ReachPageContentCollectionSerializer.cs
- UnionExpr.cs
- ByteAnimationUsingKeyFrames.cs
- TokenizerHelper.cs
- QuotaThrottle.cs
- BindingBase.cs
- WSSecureConversationDec2005.cs
- FastPropertyAccessor.cs
- ObjectDataSource.cs
- AppDomainManager.cs
- XmlSchemaObjectTable.cs
- MetafileHeaderWmf.cs
- TextElementCollectionHelper.cs
- RuleRef.cs
- HTMLTextWriter.cs
- BooleanKeyFrameCollection.cs
- CDSCollectionETWBCLProvider.cs
- AnnotationResource.cs
- FontFamily.cs
- FontFaceLayoutInfo.cs
- DateTimeOffsetConverter.cs
- DataViewManagerListItemTypeDescriptor.cs
- ThreadAbortException.cs
- CalloutQueueItem.cs
- ImageClickEventArgs.cs
- ExpressionVisitorHelpers.cs
- XmlSchemaSequence.cs
- XsltException.cs
- _BaseOverlappedAsyncResult.cs
- lengthconverter.cs
- ColorContextHelper.cs
- PackageStore.cs
- ConfigXmlSignificantWhitespace.cs
- ConstraintStruct.cs
- AdornerPresentationContext.cs
- WebBrowserProgressChangedEventHandler.cs
- SafeHandles.cs
- GeometryCollection.cs
- SiteMapNodeItem.cs
- AppDomainAttributes.cs
- XamlRtfConverter.cs
- ReadOnlyHierarchicalDataSourceView.cs
- GridToolTip.cs
- SegmentInfo.cs
- SelectionChangedEventArgs.cs
- FixedBufferAttribute.cs
- XmlILStorageConverter.cs
- RegexRunner.cs
- NativeMethodsOther.cs
- EntityProxyFactory.cs
- Exceptions.cs
- KeyTime.cs
- SmtpNetworkElement.cs
- NotifyCollectionChangedEventArgs.cs
- HttpGetProtocolImporter.cs
- FreeFormDragDropManager.cs
- WhitespaceSignificantCollectionAttribute.cs
- XmlDataCollection.cs
- PerfCounters.cs
- DataGridCommandEventArgs.cs
- CalendarAutoFormatDialog.cs