Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- SortKey.cs
- MessageBox.cs
- WindowsFormsSynchronizationContext.cs
- EntityViewContainer.cs
- LayoutTableCell.cs
- BinaryObjectInfo.cs
- ObjectReaderCompiler.cs
- SpeechRecognitionEngine.cs
- DateTimeConverter2.cs
- IisTraceWebEventProvider.cs
- DrawToolTipEventArgs.cs
- securitycriticaldataformultiplegetandset.cs
- PointHitTestResult.cs
- XmlDataLoader.cs
- FacetDescriptionElement.cs
- XmlDictionaryReaderQuotas.cs
- TemplateBamlRecordReader.cs
- XmlSchemaAll.cs
- Shared.cs
- VScrollBar.cs
- DataControlButton.cs
- TransactedBatchingElement.cs
- RowUpdatingEventArgs.cs
- StatusBar.cs
- DesignerVerb.cs
- ValidatingPropertiesEventArgs.cs
- WindowManager.cs
- DllNotFoundException.cs
- FixedStringLookup.cs
- SecurityTokenResolver.cs
- DataGridViewRowCancelEventArgs.cs
- DefaultBindingPropertyAttribute.cs
- PersianCalendar.cs
- SafeNativeMethods.cs
- SchemaElementLookUpTable.cs
- FontEmbeddingManager.cs
- RbTree.cs
- RightsManagementInformation.cs
- MemberPath.cs
- RuntimeHandles.cs
- StateItem.cs
- WebPartTransformer.cs
- DSASignatureDeformatter.cs
- VisualBrush.cs
- ProcessStartInfo.cs
- PowerStatus.cs
- Substitution.cs
- PageThemeParser.cs
- FrameAutomationPeer.cs
- Parser.cs
- FastEncoderStatics.cs
- SecurityTokenException.cs
- EntityException.cs
- EntityContainer.cs
- Win32Exception.cs
- FlowDocumentFormatter.cs
- ValidationError.cs
- WindowsPrincipal.cs
- PageSettings.cs
- Types.cs
- SqlConnectionStringBuilder.cs
- autovalidator.cs
- Typeface.cs
- ClientSettingsStore.cs
- TransportSecurityHelpers.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- TextPenaltyModule.cs
- UpdateTranslator.cs
- FontUnitConverter.cs
- ActiveDocumentEvent.cs
- OleDbRowUpdatingEvent.cs
- ListItemsCollectionEditor.cs
- Wildcard.cs
- StreamReader.cs
- ErrorWebPart.cs
- KeyPullup.cs
- DbConnectionPoolOptions.cs
- StylusPointProperty.cs
- WebSysDefaultValueAttribute.cs
- EntityDataSourceQueryBuilder.cs
- Application.cs
- SymbolMethod.cs
- ViewSimplifier.cs
- MetadataItem.cs
- StatusBar.cs
- PerformanceCounterCategory.cs
- IteratorFilter.cs
- Perspective.cs
- NativeRecognizer.cs
- glyphs.cs
- ApplicationActivator.cs
- CriticalHandle.cs
- SqlHelper.cs
- FixedStringLookup.cs
- KnownIds.cs
- DataContractSerializerOperationGenerator.cs
- ZipIOZip64EndOfCentralDirectoryBlock.cs
- TemplatedMailWebEventProvider.cs
- IItemProperties.cs
- WizardDesigner.cs