Code:
/ 4.0 / 4.0 / 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. //------------------------------------------------------------------------ // // 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 IEnumerable TypeReferences(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
- WindowsSidIdentity.cs
- AdRotator.cs
- WebPartMenu.cs
- WebPartPersonalization.cs
- WebPartTransformerCollection.cs
- DescendantBaseQuery.cs
- BindingBase.cs
- ListItemCollection.cs
- WebHttpSecurity.cs
- CompoundFileIOPermission.cs
- PartialCachingControl.cs
- QilFactory.cs
- NextPreviousPagerField.cs
- CompressionTransform.cs
- BindingObserver.cs
- WindowsSolidBrush.cs
- BindingListCollectionView.cs
- SimpleApplicationHost.cs
- WindowsStatic.cs
- FontStretch.cs
- DPTypeDescriptorContext.cs
- FileDialogPermission.cs
- TextRangeProviderWrapper.cs
- BaseParaClient.cs
- VerificationAttribute.cs
- arclist.cs
- DataProtectionSecurityStateEncoder.cs
- DrawingGroupDrawingContext.cs
- HyperLinkColumn.cs
- HtmlElementErrorEventArgs.cs
- MobileDeviceCapabilitiesSectionHandler.cs
- AttributeTableBuilder.cs
- BackgroundFormatInfo.cs
- FileEnumerator.cs
- BrowserDefinition.cs
- GridViewSelectEventArgs.cs
- VScrollBar.cs
- NeutralResourcesLanguageAttribute.cs
- DataViewManagerListItemTypeDescriptor.cs
- EntityRecordInfo.cs
- LookupTables.cs
- TemplateContent.cs
- ExeConfigurationFileMap.cs
- ElementMarkupObject.cs
- DataRelationCollection.cs
- DataGridViewLinkColumn.cs
- SqlPersonalizationProvider.cs
- HtmlShimManager.cs
- StoryFragments.cs
- CodeDOMUtility.cs
- FocusManager.cs
- JsonDeserializer.cs
- XPathException.cs
- ObjectManager.cs
- DataSourceCache.cs
- FilteredReadOnlyMetadataCollection.cs
- VariantWrapper.cs
- MouseEvent.cs
- OleStrCAMarshaler.cs
- CatalogZoneBase.cs
- SmiEventSink.cs
- IndicShape.cs
- BaseTemplateCodeDomTreeGenerator.cs
- Decoder.cs
- BinaryReader.cs
- OleDbCommand.cs
- CornerRadius.cs
- PriorityQueue.cs
- TracingConnectionListener.cs
- GPStream.cs
- RequestCachePolicyConverter.cs
- ScrollBar.cs
- RowToFieldTransformer.cs
- SystemTcpStatistics.cs
- ControlParameter.cs
- StylusEventArgs.cs
- XslAstAnalyzer.cs
- RowCache.cs
- PrinterResolution.cs
- httpserverutility.cs
- AppDomainManager.cs
- SettingsPropertyValueCollection.cs
- GetReadStreamResult.cs
- SecurityIdentifierConverter.cs
- ipaddressinformationcollection.cs
- GorillaCodec.cs
- QilGenerator.cs
- GAC.cs
- EncodingTable.cs
- RelationshipDetailsRow.cs
- DataObjectMethodAttribute.cs
- CqlParserHelpers.cs
- UpdatePanel.cs
- BitmapCodecInfoInternal.cs
- XPathEmptyIterator.cs
- NumericExpr.cs
- FindCompletedEventArgs.cs
- CellIdBoolean.cs
- SqlDataSourceStatusEventArgs.cs
- PropertyManager.cs