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
- GeometryModel3D.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- XslAst.cs
- XMLDiffLoader.cs
- ClientSession.cs
- XPathAncestorQuery.cs
- ContentPlaceHolderDesigner.cs
- MimeTypeMapper.cs
- ParameterBinding.cs
- FunctionImportElement.cs
- ImageBrush.cs
- ProtectedProviderSettings.cs
- LabelDesigner.cs
- PnrpPeerResolverElement.cs
- SessionEndingCancelEventArgs.cs
- SocketCache.cs
- OAVariantLib.cs
- EmptyStringExpandableObjectConverter.cs
- XamlLoadErrorInfo.cs
- LoadWorkflowByInstanceKeyCommand.cs
- DynamicValidatorEventArgs.cs
- CompareInfo.cs
- XmlSubtreeReader.cs
- ListViewGroup.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- Query.cs
- Identity.cs
- HttpTransportElement.cs
- SynchronizedRandom.cs
- SettingsAttributes.cs
- SwitchLevelAttribute.cs
- basevalidator.cs
- PhotoPrintingIntent.cs
- TextBoxBase.cs
- FormsIdentity.cs
- LateBoundBitmapDecoder.cs
- ArrayWithOffset.cs
- BindUriHelper.cs
- TransportContext.cs
- EdmProviderManifest.cs
- UseAttributeSetsAction.cs
- AspNetSynchronizationContext.cs
- XmlCharCheckingReader.cs
- DiagnosticTrace.cs
- InputChannelAcceptor.cs
- XmlStreamStore.cs
- StoreItemCollection.Loader.cs
- DynamicAttribute.cs
- UpWmlMobileTextWriter.cs
- Point4D.cs
- PerformanceCounterPermissionEntryCollection.cs
- ZipIOCentralDirectoryFileHeader.cs
- DocumentOutline.cs
- KeyTime.cs
- ConfigurationSettings.cs
- XmlSchemaDatatype.cs
- PersistNameAttribute.cs
- TcpDuplicateContext.cs
- DirectoryInfo.cs
- SaveFileDialog.cs
- DesignTimeTemplateParser.cs
- WaitHandleCannotBeOpenedException.cs
- HttpModuleAction.cs
- MSAAEventDispatcher.cs
- NavigationService.cs
- XPathDocumentBuilder.cs
- WebPartConnectionsCancelEventArgs.cs
- UrlMappingCollection.cs
- FontNamesConverter.cs
- BindingManagerDataErrorEventArgs.cs
- DrawListViewItemEventArgs.cs
- EnterpriseServicesHelper.cs
- latinshape.cs
- InstanceCreationEditor.cs
- ReadOnlyDictionary.cs
- EntityContainer.cs
- Helpers.cs
- TextTreeUndo.cs
- UnsafeNativeMethods.cs
- ObjectListComponentEditor.cs
- MatrixKeyFrameCollection.cs
- SchemaNamespaceManager.cs
- XmlSchemaComplexContentExtension.cs
- PermissionSetEnumerator.cs
- OfTypeExpression.cs
- EmptyReadOnlyDictionaryInternal.cs
- PersonalizationStateInfoCollection.cs
- CompiledRegexRunnerFactory.cs
- ViewBox.cs
- _AuthenticationState.cs
- ButtonBaseAutomationPeer.cs
- TextBox.cs
- DrawListViewSubItemEventArgs.cs
- WindowsStartMenu.cs
- WsdlServiceChannelBuilder.cs
- DocumentReference.cs
- PersonalizationAdministration.cs
- ServiceHostingEnvironment.cs
- TextTreeInsertUndoUnit.cs
- QualifiedId.cs