Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / 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 chuckj // //----------------------------------------------------------------------- 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebPart.cs
- PackageRelationshipCollection.cs
- BuildTopDownAttribute.cs
- SQLSingle.cs
- OdbcError.cs
- RuleElement.cs
- TypeForwardedToAttribute.cs
- FormViewDeleteEventArgs.cs
- ContentDesigner.cs
- ClientCultureInfo.cs
- EditorPartChrome.cs
- QilNode.cs
- Registry.cs
- VersionValidator.cs
- Scene3D.cs
- SafeHandles.cs
- Point3DAnimationBase.cs
- AutoGeneratedField.cs
- TemplateEditingFrame.cs
- Memoizer.cs
- StringStorage.cs
- PerformanceCountersElement.cs
- FormViewPageEventArgs.cs
- ProjectionPath.cs
- _TLSstream.cs
- CommandManager.cs
- SafeFileHandle.cs
- AssemblyInfo.cs
- HebrewCalendar.cs
- RegexTypeEditor.cs
- UserControl.cs
- EntityProviderFactory.cs
- parserscommon.cs
- ManagedFilter.cs
- AssociatedControlConverter.cs
- ActionMessageFilter.cs
- ChangesetResponse.cs
- Calendar.cs
- XPathNavigatorReader.cs
- QueryOperatorEnumerator.cs
- EncoderBestFitFallback.cs
- ProtocolsConfigurationEntry.cs
- DbProviderFactoriesConfigurationHandler.cs
- ContainerSelectorBehavior.cs
- Int32KeyFrameCollection.cs
- CharacterBuffer.cs
- SymmetricKey.cs
- ReadOnlyMetadataCollection.cs
- VisualBrush.cs
- ContentDisposition.cs
- SettingsPropertyIsReadOnlyException.cs
- CodeCatchClauseCollection.cs
- TransmissionStrategy.cs
- ObjectCloneHelper.cs
- ExtendedPropertyCollection.cs
- LeafCellTreeNode.cs
- SettingsPropertyCollection.cs
- CryptoApi.cs
- FlowLayout.cs
- TaskFormBase.cs
- TypeDelegator.cs
- ImmutableObjectAttribute.cs
- DataRowComparer.cs
- EntityContainerRelationshipSet.cs
- SafeNativeMemoryHandle.cs
- X509UI.cs
- XmlDataSourceNodeDescriptor.cs
- DispatchChannelSink.cs
- LinqTreeNodeEvaluator.cs
- ContactManager.cs
- AspNetRouteServiceHttpHandler.cs
- SearchForVirtualItemEventArgs.cs
- XmlAttributeOverrides.cs
- HtmlTextArea.cs
- keycontainerpermission.cs
- Assert.cs
- RemoteCryptoSignHashRequest.cs
- HideDisabledControlAdapter.cs
- WeakReferenceList.cs
- ContentIterators.cs
- CompilerState.cs
- GrammarBuilderPhrase.cs
- ObjectContext.cs
- PreloadedPackages.cs
- HttpException.cs
- linebase.cs
- SafeNativeMemoryHandle.cs
- Oid.cs
- OrderedDictionary.cs
- SHA512Managed.cs
- Button.cs
- UriParserTemplates.cs
- VirtualDirectoryMapping.cs
- CheckableControlBaseAdapter.cs
- FlowThrottle.cs
- _Events.cs
- Executor.cs
- ListViewItemEventArgs.cs
- Authorization.cs
- SqlSupersetValidator.cs