Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RawAppCommandInputReport.cs
- CommentAction.cs
- StdValidatorsAndConverters.cs
- NewArrayExpression.cs
- RecognizerInfo.cs
- ClrPerspective.cs
- XmlSchemaType.cs
- Propagator.cs
- TopClause.cs
- AttachInfo.cs
- ArgumentException.cs
- SecurityVersion.cs
- DataPagerCommandEventArgs.cs
- OracleRowUpdatedEventArgs.cs
- DBSqlParserTableCollection.cs
- LoadItemsEventArgs.cs
- ErrorWebPart.cs
- DataBinder.cs
- NameSpaceEvent.cs
- ExpandCollapseProviderWrapper.cs
- LayoutInformation.cs
- DataControlImageButton.cs
- SettingsPropertyNotFoundException.cs
- ToggleButtonAutomationPeer.cs
- StateWorkerRequest.cs
- SwitchAttribute.cs
- ObjectKeyFrameCollection.cs
- PackagingUtilities.cs
- DebuggerService.cs
- Attribute.cs
- SqlGatherProducedAliases.cs
- Empty.cs
- Stroke2.cs
- IisTraceWebEventProvider.cs
- NoClickablePointException.cs
- ArraySubsetEnumerator.cs
- Utils.cs
- X509ClientCertificateAuthenticationElement.cs
- ControlIdConverter.cs
- XsltOutput.cs
- ColumnTypeConverter.cs
- StorageMappingItemLoader.cs
- PassportAuthentication.cs
- DataPointer.cs
- SqlStatistics.cs
- PolyLineSegment.cs
- DataFieldConverter.cs
- SortedDictionary.cs
- BindingsCollection.cs
- VectorKeyFrameCollection.cs
- BoundColumn.cs
- SerializationException.cs
- WsdlServiceChannelBuilder.cs
- TextServicesProperty.cs
- PostBackTrigger.cs
- Int32AnimationUsingKeyFrames.cs
- TransportManager.cs
- Win32Native.cs
- DataGridItemCollection.cs
- FixedTextPointer.cs
- XmlWrappingWriter.cs
- Exception.cs
- CannotUnloadAppDomainException.cs
- SourceSwitch.cs
- ImageConverter.cs
- EmbeddedObject.cs
- ScrollableControl.cs
- Rotation3DKeyFrameCollection.cs
- EdmValidator.cs
- XsltLibrary.cs
- HttpModuleAction.cs
- XmlNodeChangedEventArgs.cs
- securitycriticaldataClass.cs
- WindowsGraphicsWrapper.cs
- IsolationInterop.cs
- TypeUnloadedException.cs
- RequestSecurityTokenResponse.cs
- ExtensibleClassFactory.cs
- PropertyValueUIItem.cs
- ToolStripScrollButton.cs
- TextLine.cs
- CommonGetThemePartSize.cs
- BrushConverter.cs
- FileSystemInfo.cs
- MaskedTextBox.cs
- MdiWindowListStrip.cs
- BuildProvider.cs
- EventHandlersStore.cs
- ExceptionHandlerDesigner.cs
- TagNameToTypeMapper.cs
- SafeFileMappingHandle.cs
- SchemaEntity.cs
- FragmentQueryKB.cs
- TreeNodeCollection.cs
- RightNameExpirationInfoPair.cs
- SwitchAttribute.cs
- ListManagerBindingsCollection.cs
- SqlCacheDependencyDatabaseCollection.cs
- Attribute.cs
- LocatorBase.cs