Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Base / System / Windows / DependencyPropertyValueSerializer.cs / 1 / 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
- DbProviderFactoriesConfigurationHandler.cs
- DataObject.cs
- CompressEmulationStream.cs
- TagElement.cs
- FigureParaClient.cs
- AbstractSvcMapFileLoader.cs
- dsa.cs
- MenuItem.cs
- ApplyTemplatesAction.cs
- ApplicationContext.cs
- SqlDependencyUtils.cs
- PenContexts.cs
- AccessDataSourceDesigner.cs
- WebPartsPersonalizationAuthorization.cs
- PersistChildrenAttribute.cs
- SQLBinaryStorage.cs
- InvalidComObjectException.cs
- ExpressionConverter.cs
- xmlglyphRunInfo.cs
- DataTableReader.cs
- VarInfo.cs
- ContentValidator.cs
- Roles.cs
- IERequestCache.cs
- ImportCatalogPart.cs
- FacetDescriptionElement.cs
- RbTree.cs
- WebPartCloseVerb.cs
- GridViewUpdatedEventArgs.cs
- EmissiveMaterial.cs
- AbandonedMutexException.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- AccessDataSource.cs
- Maps.cs
- MatrixAnimationBase.cs
- GcSettings.cs
- QuaternionValueSerializer.cs
- Reference.cs
- JournalEntryListConverter.cs
- XmlSchemaObject.cs
- TempFiles.cs
- CalloutQueueItem.cs
- CodePageEncoding.cs
- SizeFConverter.cs
- FontCacheUtil.cs
- TypeBuilder.cs
- RoleManagerModule.cs
- MethodBuilder.cs
- GridItemCollection.cs
- Span.cs
- KeySpline.cs
- Bookmark.cs
- CreateUserWizardStep.cs
- WebDisplayNameAttribute.cs
- ViewCellSlot.cs
- ReferenceEqualityComparer.cs
- DataKey.cs
- VisualStyleInformation.cs
- XmlSiteMapProvider.cs
- SqlNodeTypeOperators.cs
- WindowsTab.cs
- MiniLockedBorderGlyph.cs
- WindowsFormsHostAutomationPeer.cs
- StylusCollection.cs
- TextEndOfParagraph.cs
- TextEditorSpelling.cs
- RecipientInfo.cs
- XmlNode.cs
- UserUseLicenseDictionaryLoader.cs
- CrossContextChannel.cs
- DashStyle.cs
- MD5CryptoServiceProvider.cs
- ColumnClickEvent.cs
- LongValidator.cs
- XpsInterleavingPolicy.cs
- StrokeRenderer.cs
- HtmlEmptyTagControlBuilder.cs
- CreatingCookieEventArgs.cs
- DataShape.cs
- MarkupCompilePass2.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- GiveFeedbackEventArgs.cs
- RouteData.cs
- ReturnEventArgs.cs
- FilterEventArgs.cs
- IgnoreFileBuildProvider.cs
- PersonalizationState.cs
- SQLInt32Storage.cs
- MouseGestureConverter.cs
- AddressAlreadyInUseException.cs
- CodeAccessPermission.cs
- DynamicMethod.cs
- Geometry.cs
- SqlColumnizer.cs
- Label.cs
- MatcherBuilder.cs
- DbConnectionPoolCounters.cs
- DocumentApplicationJournalEntry.cs
- ConstNode.cs
- WebPartVerb.cs