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
- ScriptIgnoreAttribute.cs
- TableColumnCollectionInternal.cs
- EntityModelBuildProvider.cs
- XmlSchemaInfo.cs
- FileVersionInfo.cs
- JsonEnumDataContract.cs
- DbParameterCollectionHelper.cs
- NameValuePair.cs
- DataRecordInternal.cs
- IntMinMaxAggregationOperator.cs
- PerformanceCounterManager.cs
- MaskInputRejectedEventArgs.cs
- SQLInt32Storage.cs
- InstanceKeyNotReadyException.cs
- ExpandCollapseProviderWrapper.cs
- StatusBar.cs
- Vector3DConverter.cs
- XmlAttributes.cs
- CachedFontFamily.cs
- Span.cs
- WebBaseEventKeyComparer.cs
- WebBrowserSiteBase.cs
- MetadataArtifactLoaderFile.cs
- ConfigurationStrings.cs
- InvokeMethod.cs
- LogicalExpressionEditor.cs
- HttpDebugHandler.cs
- HttpModuleCollection.cs
- COM2PropertyDescriptor.cs
- XmlSchemaExporter.cs
- _emptywebproxy.cs
- Collection.cs
- TextTreeRootTextBlock.cs
- RtfNavigator.cs
- HttpListenerContext.cs
- SystemWebSectionGroup.cs
- DataBinding.cs
- SecurityKeyIdentifier.cs
- ExplicitDiscriminatorMap.cs
- MimeTypePropertyAttribute.cs
- CatalogPartChrome.cs
- StickyNoteHelper.cs
- DrawListViewItemEventArgs.cs
- BigInt.cs
- SrgsElementFactoryCompiler.cs
- XmlAutoDetectWriter.cs
- CharUnicodeInfo.cs
- SecurityTokenException.cs
- TreeNodeCollection.cs
- LineGeometry.cs
- WebPartMenuStyle.cs
- ItemCheckEvent.cs
- CompositeDataBoundControl.cs
- ObjectParameter.cs
- ObjRef.cs
- CheckedPointers.cs
- SqlRowUpdatingEvent.cs
- InvalidProgramException.cs
- CompilerState.cs
- MetafileHeaderWmf.cs
- TranslateTransform3D.cs
- TypeConverterHelper.cs
- SettingsSection.cs
- EventsTab.cs
- HwndHostAutomationPeer.cs
- ChildDocumentBlock.cs
- StateMachineExecutionState.cs
- CodeSnippetCompileUnit.cs
- DataBoundControlHelper.cs
- FolderNameEditor.cs
- FixedSOMPageConstructor.cs
- ImageDrawing.cs
- SchemaSetCompiler.cs
- DelegatingMessage.cs
- ManipulationStartingEventArgs.cs
- XmlToDatasetMap.cs
- StrongNameMembershipCondition.cs
- KnowledgeBase.cs
- CreateUserWizardAutoFormat.cs
- XmlSchemaObjectTable.cs
- ViewManager.cs
- SqlBooleanizer.cs
- UnhandledExceptionEventArgs.cs
- ExpressionEditorAttribute.cs
- HandlerBase.cs
- EntityDataSourceView.cs
- ClassImporter.cs
- AuthorizationRule.cs
- RecipientInfo.cs
- ProfessionalColorTable.cs
- FileVersionInfo.cs
- InitializeCorrelation.cs
- TranslateTransform3D.cs
- OutArgumentConverter.cs
- DisableDpiAwarenessAttribute.cs
- EpmSourceTree.cs
- EmptyImpersonationContext.cs
- HttpResponseBase.cs
- WindowsListView.cs
- DecimalConverter.cs