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
- LocatorManager.cs
- SqlUDTStorage.cs
- DecimalConstantAttribute.cs
- FormatConvertedBitmap.cs
- TextComposition.cs
- WindowsFormsHost.cs
- wgx_sdk_version.cs
- EmbeddedMailObjectCollectionEditor.cs
- FormCollection.cs
- OdbcRowUpdatingEvent.cs
- HttpRawResponse.cs
- DataTableExtensions.cs
- HttpDictionary.cs
- DocumentOrderComparer.cs
- UnsafeNativeMethodsPenimc.cs
- NativeMethods.cs
- UnknownWrapper.cs
- AudioFormatConverter.cs
- CommandBindingCollection.cs
- FormViewCommandEventArgs.cs
- SqlServices.cs
- RSAOAEPKeyExchangeFormatter.cs
- controlskin.cs
- DataControlImageButton.cs
- ProxyHwnd.cs
- ButtonRenderer.cs
- XmlIterators.cs
- ObjectView.cs
- CreateDataSourceDialog.cs
- ReceiveMessageRecord.cs
- FormatSelectingMessageInspector.cs
- Tracking.cs
- SectionUpdates.cs
- FixedPageStructure.cs
- WorkflowInstance.cs
- IntAverageAggregationOperator.cs
- CategoryNameCollection.cs
- DoubleAnimationBase.cs
- TreeView.cs
- Mutex.cs
- ConnectivityStatus.cs
- SpeechDetectedEventArgs.cs
- PropertyDescriptorCollection.cs
- BooleanProjectedSlot.cs
- CompilerGeneratedAttribute.cs
- Accessible.cs
- PageRanges.cs
- ConvertBinder.cs
- ProfilePropertySettingsCollection.cs
- FormViewModeEventArgs.cs
- Tokenizer.cs
- ResourceSet.cs
- TextEndOfLine.cs
- WpfGeneratedKnownProperties.cs
- MembershipValidatePasswordEventArgs.cs
- ControlBindingsConverter.cs
- ListItemConverter.cs
- Rules.cs
- XmlProcessingInstruction.cs
- AutoResizedEvent.cs
- Int32Converter.cs
- ReachObjectContext.cs
- JsonUriDataContract.cs
- documentation.cs
- messageonlyhwndwrapper.cs
- Validator.cs
- TableLayoutPanelCellPosition.cs
- GlyphElement.cs
- BulletChrome.cs
- OLEDB_Enum.cs
- UnsettableComboBox.cs
- OdbcException.cs
- CircleEase.cs
- DrawingAttributes.cs
- XmlWellformedWriter.cs
- DataIdProcessor.cs
- DeviceSpecific.cs
- WindowPattern.cs
- RijndaelManagedTransform.cs
- ListViewGroupConverter.cs
- Debugger.cs
- ColorTransform.cs
- DependencySource.cs
- NetworkCredential.cs
- ClientFormsIdentity.cs
- WsdlBuildProvider.cs
- Pkcs7Signer.cs
- CodePrimitiveExpression.cs
- RegistryKey.cs
- ListControlStringCollectionEditor.cs
- RemoteWebConfigurationHostServer.cs
- DocobjHost.cs
- ValidationHelper.cs
- HtmlPageAdapter.cs
- ConfigXmlSignificantWhitespace.cs
- AuthenticationService.cs
- TextWriterEngine.cs
- DynamicResourceExtensionConverter.cs
- PrinterSettings.cs
- CodeTypeDeclarationCollection.cs