Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- Debug.cs
- CatalogZoneBase.cs
- Or.cs
- SqlBooleanMismatchVisitor.cs
- XmlAttributes.cs
- SqlUserDefinedAggregateAttribute.cs
- QilScopedVisitor.cs
- DecoderBestFitFallback.cs
- ConnectionPointCookie.cs
- ColorConvertedBitmap.cs
- SessionEndedEventArgs.cs
- DiscoveryMessageSequenceCD1.cs
- TrackingWorkflowEventArgs.cs
- MDIWindowDialog.cs
- SubstitutionList.cs
- SecureStringHasher.cs
- TemplateControlParser.cs
- GridItemCollection.cs
- NativeWindow.cs
- AttributedMetaModel.cs
- GridSplitterAutomationPeer.cs
- QilStrConcat.cs
- SuppressMergeCheckAttribute.cs
- TextBoxBase.cs
- HttpListenerTimeoutManager.cs
- FixedSOMElement.cs
- OleDbPropertySetGuid.cs
- EntityWithChangeTrackerStrategy.cs
- EventLogEntryCollection.cs
- MetadataSource.cs
- TextAutomationPeer.cs
- UncommonField.cs
- NoneExcludedImageIndexConverter.cs
- FormsIdentity.cs
- arabicshape.cs
- OracleDataReader.cs
- DebugHandleTracker.cs
- XmlILAnnotation.cs
- DocumentDesigner.cs
- ConfigurationException.cs
- SystemIPGlobalStatistics.cs
- TrackingRecordPreFilter.cs
- IdentityHolder.cs
- SoapIgnoreAttribute.cs
- WebPartDescription.cs
- XPathParser.cs
- ToolStripCollectionEditor.cs
- LinkTarget.cs
- SystemColors.cs
- CultureInfoConverter.cs
- BitStream.cs
- DateTimeStorage.cs
- WSSecurityJan2004.cs
- ModuleConfigurationInfo.cs
- IgnoreSectionHandler.cs
- ClrPerspective.cs
- HttpCachePolicy.cs
- BezierSegment.cs
- DbConnectionFactory.cs
- DbConnectionPoolCounters.cs
- CompositeDispatchFormatter.cs
- SecurityTokenRequirement.cs
- Parser.cs
- DataGridCaption.cs
- BitmapCacheBrush.cs
- ExceptionRoutedEventArgs.cs
- CombinedGeometry.cs
- DataGridTemplateColumn.cs
- DefaultEventAttribute.cs
- PrincipalPermission.cs
- TextElement.cs
- ProjectionPlan.cs
- DataGridCell.cs
- MonitoringDescriptionAttribute.cs
- EventData.cs
- DataGridItemCollection.cs
- EventListener.cs
- TdsValueSetter.cs
- DataSourceControl.cs
- ContainerParaClient.cs
- ToolStripGripRenderEventArgs.cs
- OledbConnectionStringbuilder.cs
- KeyboardDevice.cs
- BamlBinaryReader.cs
- Part.cs
- DesignerActionList.cs
- ResumeStoryboard.cs
- XmlSignificantWhitespace.cs
- TemplateInstanceAttribute.cs
- RightsManagementEncryptionTransform.cs
- FacetChecker.cs
- ProjectionCamera.cs
- OleDbConnectionInternal.cs
- Button.cs
- PatternMatcher.cs
- RangeContentEnumerator.cs
- XmlSerializerFactory.cs
- SmtpException.cs
- CacheHelper.cs
- ServicePointManager.cs