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
- RepeaterItemEventArgs.cs
- ImportCatalogPart.cs
- WebContext.cs
- GeneralTransform3D.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- WSHttpBindingElement.cs
- WebHttpBinding.cs
- Inline.cs
- TypefaceMetricsCache.cs
- DecimalConverter.cs
- StyleCollectionEditor.cs
- Zone.cs
- XhtmlMobileTextWriter.cs
- SerialPort.cs
- HttpCachePolicyBase.cs
- ToolStripScrollButton.cs
- ListItemCollection.cs
- ArraySubsetEnumerator.cs
- EqualityComparer.cs
- Directory.cs
- Version.cs
- XslCompiledTransform.cs
- TextTreeInsertUndoUnit.cs
- ConstructorBuilder.cs
- ExpressionVisitorHelpers.cs
- MetadataException.cs
- CodeArgumentReferenceExpression.cs
- FileIOPermission.cs
- TrustLevelCollection.cs
- Overlapped.cs
- TransactionScope.cs
- ComponentChangedEvent.cs
- URI.cs
- TextServicesCompartment.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- nulltextnavigator.cs
- TimeZoneNotFoundException.cs
- JournalEntryListConverter.cs
- NullableIntSumAggregationOperator.cs
- ListenerBinder.cs
- SaveRecipientRequest.cs
- SchemaHelper.cs
- OpenFileDialog.cs
- PropertyInfo.cs
- FixedFindEngine.cs
- SafeMILHandle.cs
- SimplePropertyEntry.cs
- DbMetaDataColumnNames.cs
- SizeConverter.cs
- UniqueIdentifierService.cs
- DbModificationCommandTree.cs
- StrongNameUtility.cs
- DataGridToolTip.cs
- MenuItem.cs
- TTSVoice.cs
- XmlQuerySequence.cs
- XhtmlBasicPageAdapter.cs
- ObjectHandle.cs
- DataListItemCollection.cs
- ObjectContext.cs
- EFAssociationProvider.cs
- ExpressionVisitorHelpers.cs
- FormViewInsertedEventArgs.cs
- XmlNode.cs
- SmiEventStream.cs
- IssuedTokenServiceElement.cs
- ParallelDesigner.cs
- DynamicVirtualDiscoSearcher.cs
- TextModifierScope.cs
- SQLDateTimeStorage.cs
- LineSegment.cs
- AppDomainAttributes.cs
- DLinqTableProvider.cs
- ByteStreamMessageEncoder.cs
- wgx_exports.cs
- ActiveXHost.cs
- PostBackOptions.cs
- DocumentApplicationDocumentViewer.cs
- ContextBase.cs
- MsdtcWrapper.cs
- IDispatchConstantAttribute.cs
- FlowPosition.cs
- UnsafeNativeMethods.cs
- XmlEnumAttribute.cs
- CanExecuteRoutedEventArgs.cs
- SoapCodeExporter.cs
- TemplateBindingExpression.cs
- ReadOnlyMetadataCollection.cs
- SectionVisual.cs
- ClientTargetSection.cs
- InlinedAggregationOperator.cs
- PasswordTextContainer.cs
- WebPartMenuStyle.cs
- AudioDeviceOut.cs
- ResolveNameEventArgs.cs
- ReachPageContentCollectionSerializerAsync.cs
- LeafCellTreeNode.cs
- ValidationErrorEventArgs.cs
- DurationConverter.cs
- Point3DIndependentAnimationStorage.cs