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
- TimestampInformation.cs
- RotationValidation.cs
- MergeEnumerator.cs
- XmlParser.cs
- SecurityPolicySection.cs
- AsnEncodedData.cs
- UpdateManifestForBrowserApplication.cs
- ObjectFullSpanRewriter.cs
- ProxyHwnd.cs
- XmlSchemaValidationException.cs
- InternalBase.cs
- Logging.cs
- HitTestParameters3D.cs
- Main.cs
- RoutedEvent.cs
- BlockUIContainer.cs
- Int64Converter.cs
- XmlObjectSerializerReadContextComplex.cs
- Font.cs
- propertytag.cs
- CopyNamespacesAction.cs
- DbExpressionVisitor.cs
- EmptyWorkItem.cs
- MetadataItem_Static.cs
- WebPartEditVerb.cs
- PngBitmapEncoder.cs
- TableRowGroup.cs
- DeviceContext2.cs
- MSAAEventDispatcher.cs
- WebBrowserBase.cs
- XmlTextWriter.cs
- EffectiveValueEntry.cs
- ErrorFormatter.cs
- RoutedEventArgs.cs
- RemotingAttributes.cs
- GenerateTemporaryAssemblyTask.cs
- DataStreamFromComStream.cs
- MailWriter.cs
- TextSelectionHighlightLayer.cs
- Parameter.cs
- BypassElementCollection.cs
- ImportCatalogPart.cs
- AliasedSlot.cs
- TableAdapterManagerNameHandler.cs
- Point3DAnimationBase.cs
- SqlGenericUtil.cs
- BitmapEffectInputData.cs
- SqlDataSourceFilteringEventArgs.cs
- ResourceReader.cs
- WizardForm.cs
- GetPageNumberCompletedEventArgs.cs
- CustomSignedXml.cs
- SRDisplayNameAttribute.cs
- _RegBlobWebProxyDataBuilder.cs
- CryptoKeySecurity.cs
- HandlerMappingMemo.cs
- SemaphoreFullException.cs
- CacheHelper.cs
- SubtreeProcessor.cs
- HtmlInputText.cs
- DynamicDocumentPaginator.cs
- DurableInstanceContextProvider.cs
- SettingsProperty.cs
- DataColumnChangeEvent.cs
- ContentFilePart.cs
- OciLobLocator.cs
- SecurityVerifiedMessage.cs
- DiscoveryClientReferences.cs
- SimplePropertyEntry.cs
- SafeCryptoHandles.cs
- GCHandleCookieTable.cs
- AlternateViewCollection.cs
- EdmValidator.cs
- TrackingMemoryStreamFactory.cs
- ServiceContractListItemList.cs
- MaterialGroup.cs
- ServerValidateEventArgs.cs
- BigInt.cs
- SQLInt32Storage.cs
- PointF.cs
- FormCollection.cs
- AnnouncementService.cs
- _SslSessionsCache.cs
- TypeElement.cs
- SchemaImporterExtensionsSection.cs
- DataGridViewComboBoxColumn.cs
- SpellerError.cs
- CfgArc.cs
- TableLayoutStyleCollection.cs
- RuleRef.cs
- Native.cs
- AutoScrollExpandMessageFilter.cs
- DesignerWidgets.cs
- LogStore.cs
- Panel.cs
- Win32Interop.cs
- FastEncoderStatics.cs
- XmlQueryOutput.cs
- FormView.cs
- TransformPatternIdentifiers.cs