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
- AssociationSetEnd.cs
- StringValueConverter.cs
- AsymmetricKeyExchangeFormatter.cs
- SafeBitVector32.cs
- RelationshipEndCollection.cs
- Image.cs
- ADMembershipProvider.cs
- InvokeWebService.cs
- Visual3D.cs
- DiagnosticsElement.cs
- AdCreatedEventArgs.cs
- MapPathBasedVirtualPathProvider.cs
- CompatibleComparer.cs
- QueryOperatorEnumerator.cs
- EntityProviderFactory.cs
- WebPartDescription.cs
- XmlWhitespace.cs
- ChooseAction.cs
- ActivationServices.cs
- ConnectionPointCookie.cs
- BuildProviderCollection.cs
- x509utils.cs
- GenericsInstances.cs
- EpmSyndicationContentSerializer.cs
- CharEnumerator.cs
- SqlUserDefinedTypeAttribute.cs
- StyleHelper.cs
- SelectionHighlightInfo.cs
- XmlSchemaException.cs
- ReversePositionQuery.cs
- DataAccessor.cs
- SendKeys.cs
- Typography.cs
- ClientProxyGenerator.cs
- RijndaelManaged.cs
- ArcSegment.cs
- AspNetSynchronizationContext.cs
- BitmapCodecInfo.cs
- EraserBehavior.cs
- ScriptManager.cs
- QilReference.cs
- VisualStyleTypesAndProperties.cs
- Lasso.cs
- OutputCacheProfile.cs
- Set.cs
- DataRecordInternal.cs
- XXXOnTypeBuilderInstantiation.cs
- ExpressionNode.cs
- FieldMetadata.cs
- InfoCardProofToken.cs
- WeakReference.cs
- DetailsViewDeleteEventArgs.cs
- PrintDialogException.cs
- SpellerInterop.cs
- FutureFactory.cs
- CodeMemberEvent.cs
- DataRowCollection.cs
- HyperLinkStyle.cs
- TargetConverter.cs
- AnchorEditor.cs
- DbConnectionPoolCounters.cs
- DoubleLinkList.cs
- TextBoxBaseDesigner.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- ExpandSegment.cs
- WebBrowser.cs
- SmiRecordBuffer.cs
- MainMenu.cs
- ScriptResourceHandler.cs
- ChtmlTextWriter.cs
- EmptyElement.cs
- PathData.cs
- ProofTokenCryptoHandle.cs
- FlowLayoutPanelDesigner.cs
- DictionaryEntry.cs
- WebPartZone.cs
- AngleUtil.cs
- BatchParser.cs
- AddressAlreadyInUseException.cs
- UInt64Converter.cs
- XmlCompatibilityReader.cs
- SQLDateTime.cs
- TemplateInstanceAttribute.cs
- sqlnorm.cs
- ToolboxCategoryItems.cs
- PropertyInformation.cs
- PolicyException.cs
- SystemPens.cs
- DATA_BLOB.cs
- SourceChangedEventArgs.cs
- CompensationTokenData.cs
- StrongNameMembershipCondition.cs
- shaper.cs
- PrintSystemException.cs
- SymLanguageType.cs
- StateWorkerRequest.cs
- ClientOptions.cs
- UnsafeNativeMethods.cs
- SynchronizationLockException.cs
- ContentAlignmentEditor.cs