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
- InputReport.cs
- ZipIOCentralDirectoryFileHeader.cs
- AnnotationHighlightLayer.cs
- ZoneLinkButton.cs
- RegionInfo.cs
- ExpressionBuilderContext.cs
- GridViewRowEventArgs.cs
- WebUtility.cs
- _LocalDataStoreMgr.cs
- DSASignatureDeformatter.cs
- DataGridViewBand.cs
- MaterialGroup.cs
- LayoutDump.cs
- Constraint.cs
- TextElementEditingBehaviorAttribute.cs
- SqlServices.cs
- FtpWebRequest.cs
- PopOutPanel.cs
- WebCategoryAttribute.cs
- PathData.cs
- Point3DCollection.cs
- XamlPointCollectionSerializer.cs
- dtdvalidator.cs
- StrokeFIndices.cs
- StringDictionary.cs
- RecordConverter.cs
- TextEncodedRawTextWriter.cs
- Function.cs
- sapiproxy.cs
- XmlSchemaComplexType.cs
- ListView.cs
- ElementsClipboardData.cs
- EntityContainerRelationshipSetEnd.cs
- FragmentQueryKB.cs
- HtmlInputText.cs
- ToggleProviderWrapper.cs
- XmlDesignerDataSourceView.cs
- HttpValueCollection.cs
- CustomGrammar.cs
- ClientConfigurationSystem.cs
- AttributeQuery.cs
- ConstructorArgumentAttribute.cs
- BuildProvidersCompiler.cs
- ServiceObjectContainer.cs
- GroupBox.cs
- KeyToListMap.cs
- OdbcDataAdapter.cs
- WebPartConnectionsCloseVerb.cs
- RuntimeEnvironment.cs
- GeneralTransform3DCollection.cs
- WindowsListViewSubItem.cs
- Operand.cs
- ResourcePermissionBase.cs
- ObjectToIdCache.cs
- GetResponse.cs
- Panel.cs
- DragEvent.cs
- SocketConnection.cs
- VisualBrush.cs
- StorageTypeMapping.cs
- TabControl.cs
- Deflater.cs
- Helper.cs
- RequiredAttributeAttribute.cs
- CoTaskMemUnicodeSafeHandle.cs
- MutexSecurity.cs
- TdsRecordBufferSetter.cs
- SqlRewriteScalarSubqueries.cs
- DataRecordInfo.cs
- CustomAttributeBuilder.cs
- DataSysAttribute.cs
- cookieexception.cs
- ReadOnlyDataSource.cs
- Control.cs
- EventLogPermissionEntry.cs
- ConfigurationManagerHelperFactory.cs
- SqlRowUpdatingEvent.cs
- SessionPageStateSection.cs
- XmlDictionaryWriter.cs
- RunClient.cs
- PenContexts.cs
- HttpModuleAction.cs
- TextServicesProperty.cs
- SmtpException.cs
- MeasureData.cs
- TTSEngineTypes.cs
- TimersDescriptionAttribute.cs
- PageParserFilter.cs
- BitVector32.cs
- ExpressionBuilder.cs
- XPathScanner.cs
- CustomTypeDescriptor.cs
- PageSetupDialog.cs
- FormViewPageEventArgs.cs
- DataViewListener.cs
- Serializer.cs
- PerformanceCounterPermissionAttribute.cs
- PartialClassGenerationTaskInternal.cs
- PTUtility.cs
- AmbientLight.cs